Skip to content

Commit 9e1bcd8

Browse files
committed
fix: cross-platform build and document auth server timing
- Fix pgai/package.json sed command for macOS compatibility - Add JSDoc documentation for auth server async stop behavior
1 parent f02d570 commit 9e1bcd8

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

cli/lib/auth-server.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,17 @@ function escapeHtml(str: string | null): string {
3232

3333
/**
3434
* Create and start callback server using Bun.serve
35+
*
3536
* @param port - Port to listen on (0 for random available port)
3637
* @param expectedState - Expected state parameter for CSRF protection
3738
* @param timeoutMs - Timeout in milliseconds
3839
* @returns Server object with promise and getPort function
40+
*
41+
* @remarks
42+
* The server stops asynchronously ~100ms after the callback resolves/rejects.
43+
* This delay ensures the HTTP response is fully sent before closing the connection.
44+
* Callers should not attempt to reuse the same port immediately after the promise
45+
* resolves - wait at least 200ms or use a different port.
3946
*/
4047
export function createCallbackServer(
4148
port: number = 0,

pgai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"node": ">=18"
2121
},
2222
"scripts": {
23-
"build": "bun build ./bin/pgai.ts --outdir ./dist/bin --target node && sed -i '1s|#!/usr/bin/env bun|#!/usr/bin/env node|' ./dist/bin/pgai.js",
23+
"build": "bun build ./bin/pgai.ts --outdir ./dist/bin --target node && node -e \"const fs=require('fs');const f='./dist/bin/pgai.js';fs.writeFileSync(f,fs.readFileSync(f,'utf8').replace('#!/usr/bin/env bun','#!/usr/bin/env node'))\"",
2424
"prepublishOnly": "npm run build"
2525
},
2626
"dependencies": {

0 commit comments

Comments
 (0)