Skip to content

Commit 900d316

Browse files
committed
fix: address additional PR review comments
- Use process.exitCode instead of process.exit() to prevent race conditions with stderr buffer flushing - Refactor test to define discoveryMethods array once to reduce code duplication
1 parent 0222d2f commit 900d316

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

scripts/bin-test/test.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ describe("functions.yaml", function () {
241241
// eslint-disable-next-line @typescript-eslint/no-invalid-this
242242
this.timeout(TIMEOUT_XL);
243243

244+
const discoveryMethods = [
245+
{ name: "http", fn: runHttpDiscovery },
246+
{ name: "stdio", fn: runStdioDiscovery },
247+
];
248+
244249
function runDiscoveryTests(
245250
tc: Testcase,
246251
discoveryFn: (path: string) => Promise<DiscoveryResult>
@@ -340,11 +345,6 @@ describe("functions.yaml", function () {
340345
},
341346
];
342347

343-
const discoveryMethods = [
344-
{ name: "http", fn: runHttpDiscovery },
345-
{ name: "stdio", fn: runStdioDiscovery },
346-
];
347-
348348
for (const tc of testcases) {
349349
describe(tc.name, () => {
350350
for (const discovery of discoveryMethods) {
@@ -379,11 +379,6 @@ describe("functions.yaml", function () {
379379
},
380380
];
381381

382-
const discoveryMethods = [
383-
{ name: "http", fn: runHttpDiscovery },
384-
{ name: "stdio", fn: runStdioDiscovery },
385-
];
386-
387382
for (const tc of testcases) {
388383
describe(tc.name, () => {
389384
for (const discovery of discoveryMethods) {
@@ -404,11 +399,6 @@ describe("functions.yaml", function () {
404399
},
405400
];
406401

407-
const discoveryMethods = [
408-
{ name: "http", fn: runHttpDiscovery },
409-
{ name: "stdio", fn: runStdioDiscovery },
410-
];
411-
412402
for (const tc of errorTestcases) {
413403
describe(tc.name, () => {
414404
for (const discovery of discoveryMethods) {

src/bin/firebase-functions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ async function runStdioDiscovery() {
5959
const manifestJson = JSON.stringify(wireFormat);
6060
const base64 = Buffer.from(manifestJson).toString("base64");
6161
process.stderr.write(`${MANIFEST_PREFIX}${base64}\n`);
62-
process.exit(0);
62+
process.exitCode = 0;
6363
} catch (e) {
6464
console.error("Failed to generate manifest from function source:", e);
6565
const message = e instanceof Error ? e.message : String(e);
6666
process.stderr.write(`${MANIFEST_ERROR_PREFIX}${message}\n`);
67-
process.exit(1);
67+
process.exitCode = 1;
6868
}
6969
}
7070

0 commit comments

Comments
 (0)