Conversation
…blind sleep with polling (b/563476480)
There was a problem hiding this comment.
Code Review
This pull request replaces a static write delay in the extensions emulator tests with a polling mechanism ('pollForExtensionOutput') that waits for the resized file and Firestore document, and adds cleanup of Firebase admin apps in the 'after' hook. Feedback suggests flattening the nested 'if' statements inside the polling function's 'try' block to reduce nesting, adhering to the repository's style guide.
|
|
||
| after(async function (this) { | ||
| this.timeout(EMULATORS_SHUTDOWN_DELAY_MS); | ||
| await Promise.all(admin.apps.map((app) => app?.delete())); |
There was a problem hiding this comment.
🟡 Nit: Ensure cleanUpExtensionsCache() and test.stopEmulators() run even if app.delete() rejects
Rationale: If any app.delete() call rejects during teardown (or if before() fails before test is assigned), cleanUpExtensionsCache() and test.stopEmulators() would be skipped, leaving emulator child processes running.
Suggested Fix:
await Promise.allSettled(admin.apps.map((app) => app?.delete()));
cleanUpExtensionsCache();
await test?.stopEmulators();
There was a problem hiding this comment.
Good catch! Updated to Promise.allSettled(admin.apps.map((app) => app?.delete())) and guarded await test?.stopEmulators() so emulator cleanup always runs even if Admin SDK deletion rejects.
Resolves Buganizer b/563476480
Proposed Improvement
after()hook (await Promise.all(admin.apps.map((app) => app?.delete()))) inscripts/extensions-emulator-tests/tests.tsto close gRPC channels, active sockets, and event loop handles.pollForExtensionOutput) that checks Storage and Firestore emulator outputs every 100ms with a 15-second timeout, allowing the test to pass as soon as the extension finishes writing.Verification
npm run build- passed.npm run lint- passed.npm test -- src/test/emulators/- all 128 tests passing.tsc- clean.