Skip to content

Fix initdb in sandboxed Node runtimes - #1099

Closed
psh4607 wants to merge 2 commits into
electric-sql:mainfrom
psh4607:fix/GH-1082/sandboxed-exit-code
Closed

Fix initdb in sandboxed Node runtimes#1099
psh4607 wants to merge 2 commits into
electric-sql:mainfrom
psh4607:fix/GH-1082/sandboxed-exit-code

Conversation

@psh4607

@psh4607 psh4607 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

작업 배경

Node 형태의 process를 노출하지만 exitCode setter가 쓰기를 거부하는 sandbox runtime에서 정상적인 initdb 종료가 Emscripten quit_process.exitCode 쓰기로 실패했습니다.

티켓 및 링크

작업 내용

  • setter가 던질 때만 동기 initdb.callMain() 동안 writable exitCode를 가진 delegating process shim을 사용하고, 호출 후 원래 process를 복원합니다.
  • 정상 Node initdb가 기존 host process.exitCode를 덮어쓰지 않도록 호출 후 값을 복원합니다.
  • _emscripten_force_exit(0)의 예상 ExitStatus(0) throw 이후에도 Postgres module 참조를 해제합니다.
  • sandbox setter, 정상 Node exit code 보존, close 후 module 해제를 bounded child process로 회귀 검증합니다.
  • @electric-sql/pglite patch changeset을 추가합니다.

테스트

  • pnpm --dir packages/pglite build
  • pnpm --dir packages/pglite exec vitest run tests/sandboxed-exit-code.test.ts --reporter=verbose (3 passed)
  • pnpm --dir packages/pglite test (297 passed, 1 skipped)
  • pnpm --dir packages/pglite typecheck
  • pnpm --dir packages/pglite stylecheck
  • git diff --check

@psh4607
psh4607 marked this pull request as ready for review August 25, 2026 02:45
@tdrz

tdrz commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

I've taken a different approach, emscripten generated code should not set process.exitCode anymore.

@tdrz tdrz closed this Aug 26, 2026
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.

[BUG]: Cannot boot on sandboxed runtimes (Bunny Edge Scripting / Workers / Deno Deploy) — two process.exitCode writes on the boot path

2 participants