fix(async): prevent missed async errors from bypassing catch handlers (#13714)

Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
CHAEWAN KIM
2025-12-02 07:11:40 +09:00
committed by GitHub
parent 0c463e664e
commit f4babf172b
25 changed files with 102 additions and 117 deletions

View File

@@ -88,7 +88,7 @@ async function getServerStatus(
server: MCPServerConfig,
): Promise<MCPServerStatus> {
// Test all server types by attempting actual connection
return await testMCPConnection(serverName, server);
return testMCPConnection(serverName, server);
}
export async function listMcpServers(): Promise<void> {

View File

@@ -1796,12 +1796,8 @@ This extension will run the following MCP servers:
});
it('should throw an error if you request system scope', async () => {
await expect(
async () =>
await extensionManager.disableExtension(
'my-extension',
SettingScope.System,
),
await expect(async () =>
extensionManager.disableExtension('my-extension', SettingScope.System),
).rejects.toThrow('System and SystemDefaults scopes are not supported.');
});

View File

@@ -45,7 +45,7 @@ export async function requestConsentInteractive(
consentDescription: string,
addExtensionUpdateConfirmationRequest: (value: ConfirmationRequest) => void,
): Promise<boolean> {
return await promptForConsentInteractive(
return promptForConsentInteractive(
consentDescription + '\n\nDo you want to continue?',
addExtensionUpdateConfirmationRequest,
);
@@ -89,7 +89,7 @@ async function promptForConsentInteractive(
prompt: string,
addExtensionUpdateConfirmationRequest: (value: ConfirmationRequest) => void,
): Promise<boolean> {
return await new Promise<boolean>((resolve) => {
return new Promise<boolean>((resolve) => {
addExtensionUpdateConfirmationRequest({
prompt,
onConfirm: (resolvedConfirmed) => {

View File

@@ -138,7 +138,7 @@ export async function fetchReleaseFromGithub(
allowPreRelease?: boolean,
): Promise<GithubReleaseData | null> {
if (ref) {
return await fetchJson(
return fetchJson(
`https://api.github.com/repos/${owner}/${repo}/releases/tags/${ref}`,
);
}

View File

@@ -40,8 +40,6 @@ export class ExtensionStorage {
}
static async createTmpDir(): Promise<string> {
return await fs.promises.mkdtemp(
path.join(os.tmpdir(), 'gemini-extension'),
);
return fs.promises.mkdtemp(path.join(os.tmpdir(), 'gemini-extension'));
}
}

View File

@@ -22,10 +22,8 @@ vi.mock('./installationInfo.js', async () => {
};
});
vi.mock(
'./updateEventEmitter.js',
async (importOriginal) =>
await importOriginal<typeof import('./updateEventEmitter.js')>(),
vi.mock('./updateEventEmitter.js', async (importOriginal) =>
importOriginal<typeof import('./updateEventEmitter.js')>(),
);
interface MockChildProcess extends EventEmitter {

View File

@@ -191,7 +191,7 @@ export async function start_sandbox(
sandboxProcess = spawn(config.command, args, {
stdio: 'inherit',
});
return new Promise((resolve, reject) => {
return await new Promise((resolve, reject) => {
sandboxProcess?.on('error', reject);
sandboxProcess?.on('close', (code) => {
process.stdin.resume();
@@ -666,7 +666,7 @@ export async function start_sandbox(
stdio: 'inherit',
});
return new Promise<number>((resolve, reject) => {
return await new Promise<number>((resolve, reject) => {
sandboxProcess.on('error', (err) => {
coreEvents.emitFeedback('error', 'Sandbox process error', err);
reject(err);

View File

@@ -68,7 +68,7 @@ export class AgentSideConnection implements Client {
* Streams new content to the client including text, tool calls, etc.
*/
async sessionUpdate(params: schema.SessionNotification): Promise<void> {
return await this.#connection.sendNotification(
return this.#connection.sendNotification(
schema.CLIENT_METHODS.session_update,
params,
);
@@ -83,7 +83,7 @@ export class AgentSideConnection implements Client {
async requestPermission(
params: schema.RequestPermissionRequest,
): Promise<schema.RequestPermissionResponse> {
return await this.#connection.sendRequest(
return this.#connection.sendRequest(
schema.CLIENT_METHODS.session_request_permission,
params,
);
@@ -92,7 +92,7 @@ export class AgentSideConnection implements Client {
async readTextFile(
params: schema.ReadTextFileRequest,
): Promise<schema.ReadTextFileResponse> {
return await this.#connection.sendRequest(
return this.#connection.sendRequest(
schema.CLIENT_METHODS.fs_read_text_file,
params,
);
@@ -101,7 +101,7 @@ export class AgentSideConnection implements Client {
async writeTextFile(
params: schema.WriteTextFileRequest,
): Promise<schema.WriteTextFileResponse> {
return await this.#connection.sendRequest(
return this.#connection.sendRequest(
schema.CLIENT_METHODS.fs_write_text_file,
params,
);