Skip to content

Commit ac47b8b

Browse files
PlayLikeNeverB4Ubuntu
authored andcommitted
fix: fix release build error (#364)
Context https://neondb.slack.com/archives/C06HN3DFX7T/p1751464594765169 There is an error during the release build: `Module format "cjs" does not support top-level await. Use the "es" or "system" output formats rather.`. This change was introduced in #339 Reproduce by `rm -Rf node_modules && bun install && bun run build && cp dist/package*.json ./ && node pkg.js`.
1 parent d612d9d commit ac47b8b

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

src/index.ts

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -213,37 +213,39 @@ async function handleError(msg: string, err: unknown): Promise<boolean> {
213213
}
214214
}
215215

216-
// Main loop with max 2 attempts (initial + 1 retry):
217-
let attempts = 0;
218-
const MAX_ATTEMPTS = 2;
216+
void (async () => {
217+
// Main loop with max 2 attempts (initial + 1 retry):
218+
let attempts = 0;
219+
const MAX_ATTEMPTS = 2;
219220

220-
while (attempts < MAX_ATTEMPTS) {
221-
try {
222-
const args = await builder.argv;
221+
while (attempts < MAX_ATTEMPTS) {
222+
try {
223+
const args = await builder.argv;
223224

224-
// Send analytics for a successful attempt
225-
trackEvent('cli_command_success', {
226-
...getAnalyticsEventProperties(args),
227-
projectId: args.projectId,
228-
branchId: args.branchId,
229-
accountId: args.accountId,
230-
authMethod: args.authMethod,
231-
authData: args.authData,
232-
});
233-
if (args._.length === 0 || args.help) {
234-
await showHelp(builder);
235-
process.exit(0);
236-
}
225+
// Send analytics for a successful attempt
226+
trackEvent('cli_command_success', {
227+
...getAnalyticsEventProperties(args),
228+
projectId: args.projectId,
229+
branchId: args.branchId,
230+
accountId: args.accountId,
231+
authMethod: args.authMethod,
232+
authData: args.authData,
233+
});
234+
if (args._.length === 0 || args.help) {
235+
await showHelp(builder);
236+
process.exit(0);
237+
}
237238

238-
await closeAnalytics();
239-
process.exit(0);
240-
} catch (err) {
241-
attempts++;
242-
const shouldRetry = await handleError('', err);
243-
if (!shouldRetry || attempts >= MAX_ATTEMPTS) {
244239
await closeAnalytics();
245-
process.exit(1);
240+
process.exit(0);
241+
} catch (err) {
242+
attempts++;
243+
const shouldRetry = await handleError('', err);
244+
if (!shouldRetry || attempts >= MAX_ATTEMPTS) {
245+
await closeAnalytics();
246+
process.exit(1);
247+
}
248+
// If shouldRetry is true and we haven't hit max attempts, loop continues
246249
}
247-
// If shouldRetry is true and we haven't hit max attempts, loop continues
248250
}
249-
}
251+
})();

0 commit comments

Comments
 (0)