Disallow floating promises. (#14605)

This commit is contained in:
Christian Gunderman
2025-12-05 16:12:49 -08:00
committed by GitHub
parent 3cf44acc08
commit 025e450ac2
57 changed files with 128 additions and 4 deletions
+1
View File
@@ -599,6 +599,7 @@ export class Config {
}
if (this.telemetrySettings.enabled) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
initializeTelemetry(this);
}
@@ -183,6 +183,7 @@ export class MessageBus extends EventEmitter {
this.subscribe<TResponse>(responseType, responseHandler);
// Publish the request with correlation ID
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.publish({ ...request, correlationId } as TRequest);
});
}
@@ -1166,6 +1166,7 @@ describe('CoreToolScheduler request queueing', () => {
};
// Schedule the first call, which will pause execution.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
scheduler.schedule([request1], abortController.signal);
// Wait for the first call to be in the 'executing' state.
@@ -381,6 +381,7 @@ export class CoreToolScheduler {
const sharedHandler = (request: ToolConfirmationRequest) => {
// When ASK_USER policy decision is made, respond with requiresUserConfirmation=true
// to tell tools to use their legacy confirmation flow
// eslint-disable-next-line @typescript-eslint/no-floating-promises
messageBus.publish({
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
correlationId: request.correlationId,
@@ -883,8 +884,10 @@ export class CoreToolScheduler {
confirmationDetails.type === 'edit' &&
confirmationDetails.ideConfirmation
) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
confirmationDetails.ideConfirmation.then((resolution) => {
if (resolution.status === 'accepted') {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.handleConfirmationResponse(
reqInfo.callId,
confirmationDetails.onConfirm,
@@ -892,6 +895,7 @@ export class CoreToolScheduler {
signal,
);
} else {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.handleConfirmationResponse(
reqInfo.callId,
confirmationDetails.onConfirm,
@@ -776,6 +776,7 @@ export class HookEventHandler {
// Publish response through MessageBus
if (this.messageBus) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.messageBus.publish({
type: MessageBusType.HOOK_EXECUTION_RESPONSE,
correlationId: request.correlationId,
@@ -786,6 +787,7 @@ export class HookEventHandler {
} catch (error) {
// Publish error response
if (this.messageBus) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.messageBus.publish({
type: MessageBusType.HOOK_EXECUTION_RESPONSE,
correlationId: request.correlationId,
+2
View File
@@ -278,6 +278,7 @@ export class IdeClient {
});
// Ensure the mutex is released only after the diff interaction is complete.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
promise.finally(release);
return promise;
@@ -406,6 +407,7 @@ export class IdeClient {
IDEConnectionStatus.Disconnected,
'IDE integration disabled. To enable it again, run /ide enable.',
);
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.client?.close();
}
@@ -685,6 +685,7 @@ export class ShellExecutionService {
});
});
// eslint-disable-next-line @typescript-eslint/no-floating-promises
Promise.race([processingComplete, abortFired]).then(() => {
finalize();
});
@@ -284,6 +284,7 @@ export class ClearcutLogger {
event: LogEvent,
): Promise<void> {
try {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.config?.getExperimentsAsync().then((experiments) => {
if (experiments) {
const exp_id_data: EventValue[] = [
@@ -557,6 +558,7 @@ export class ClearcutLogger {
this.sessionData = data;
// Flush after experiments finish loading from CCPA server
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.enqueueLogEventAfterExperimentsLoadAsync(
this.createLogEvent(EventNames.START_SESSION, data),
).then(() => {
@@ -900,6 +902,7 @@ export class ClearcutLogger {
];
// Flush after experiments finish loading from CCPA server
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.enqueueLogEventAfterExperimentsLoadAsync(
this.createLogEvent(EventNames.START_SESSION, data),
).then(() => {
@@ -96,6 +96,7 @@ export class GcpLogExporter implements LogRecordExporter {
.finally(() => {
const index = this.pendingWrites.indexOf(writePromise);
if (index > -1) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.pendingWrites.splice(index, 1);
}
});
+3
View File
@@ -94,6 +94,7 @@ export function isTelemetrySdkInitialized(): boolean {
export function bufferTelemetryEvent(fn: () => void | Promise<void>): void {
if (telemetryInitialized) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
fn();
} else {
telemetryBuffer.push(fn);
@@ -303,9 +304,11 @@ export async function initializeTelemetry(
// and won't wait for the async shutdownTelemetry() to complete.
// Instead, telemetry shutdown is handled in runExitCleanup() in cleanup.ts
process.on('SIGTERM', () => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
shutdownTelemetry(config);
});
process.on('SIGINT', () => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
shutdownTelemetry(config);
});
}
@@ -160,6 +160,7 @@ export class McpClientManager {
}
const currentDiscoveryPromise = new Promise<void>((resolve, _reject) => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async () => {
try {
if (existing) {
@@ -228,6 +229,7 @@ export class McpClientManager {
}
this.eventEmitter?.emit('mcp-client-update', this.clients);
const currentPromise = this.discoveryPromise;
// eslint-disable-next-line @typescript-eslint/no-floating-promises
currentPromise.then((_) => {
// If we are the last recorded discoveryPromise, then we are done, reset
// the world.
+1
View File
@@ -739,6 +739,7 @@ export async function connectAndDiscover(
toolRegistry.sortTools();
} catch (error) {
if (mcpClient) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
mcpClient.close();
}
coreEvents.emitFeedback(
+2
View File
@@ -131,6 +131,7 @@ export abstract class BaseToolInvocation<
onConfirm: async (outcome: ToolConfirmationOutcome) => {
if (outcome === ToolConfirmationOutcome.ProceedAlways) {
if (this.messageBus && this._toolName) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.messageBus.publish({
type: MessageBusType.UPDATE_POLICY,
toolName: this._toolName,
@@ -220,6 +221,7 @@ export abstract class BaseToolInvocation<
};
try {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.messageBus.publish(request);
} catch (_error) {
cleanup();