Skip to content

Conversation

@joostliebregts
Copy link

Summary

On Windows, Bun exits immediately without waiting for pending promises. When hooks have async main() functions called without await, the script exits before main() completes, causing hooks to produce no output.

Changes

Changed main(); to await main(); in all 4 hooks:

  • initialize-session.ts
  • load-core-context.ts
  • security-validator.ts
  • update-tab-titles.ts

Testing

  • Tested on macOS: Works as before
  • Tested on Windows: Hooks now produce output correctly

Root Cause

async function main() {
  // async operations...
}

main();  // BUG: Script exits before promise resolves on Windows

Fix:

await main();  // Ensures async operations complete before exit

🤖 Discovered while setting up PAI cross-platform (Mac + Windows)

On Windows, Bun exits immediately without waiting for pending promises.
When hooks have async main() functions called without await, the script
exits before main() completes, causing hooks to produce no output.

This fix ensures all hook scripts properly await their async main()
functions before exiting.

Tested on both macOS and Windows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant