Skip to content

Harden JS native object lifetimes - #904

Draft
bmehta001 wants to merge 4 commits into
mainfrom
bhamehta/flcore/js-native-lifetime-hardening
Draft

Harden JS native object lifetimes#904
bmehta001 wants to merge 4 commits into
mainfrom
bhamehta/flcore/js-native-lifetime-hardening

Conversation

@bmehta001

Copy link
Copy Markdown
Contributor

Summary

  • Keep native Manager instances alive while JS Model/Session objects still depend on them.
  • Reject session creation after manager disposal and separate disposed state from native keepalive leases.
  • Add JS coverage for manager disposal behavior.

Validation

  • cd sdk_v2/js; npm run build:ts -- --pretty false
  • cd sdk_v2/js; npm run build:native
  • cd sdk_v2/js; npx vitest run test/manager-dispose.test.ts --fileParallelism=false --pool=forks --reporter=dot

Keep native managers alive while JS models and sessions reference them, reject session creation after disposal, and add disposal coverage for the JS SDK native layer.

Files changed:

- sdk_v2/js/native/src/catalog.cc/.h

- sdk_v2/js/native/src/manager.cc/.h

- sdk_v2/js/native/src/model.cc/.h

- sdk_v2/js/native/src/session.cc/.h

- sdk_v2/js/src/catalog.ts

- sdk_v2/js/test/manager-dispose.test.ts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 297bc539-5f7f-4a70-9411-48e91a5bf532
@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
foundry-local Ready Ready Preview, Comment Jul 26, 2026 10:48pm

Request Review

The test only needs to prove disposal is blocked while a native worker lease exists; the unknown-EP operation may legitimately resolve or reject. Always await it and dispose the singleton in a finally block so one assertion cannot poison later tests.

Files changed:

- sdk_v2/js/test/manager-dispose.test.ts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 297bc539-5f7f-4a70-9411-48e91a5bf532
A transient catalog response can leave no selectable cached chat model even when the test cache exists. Treat that existing environmental condition as SkipFixture in CI and dynamically skip the new disposal suite instead of failing unrelated lifecycle coverage.

Files changed:

- sdk_v2/js/test/_fixtures/realModelManager.ts

- sdk_v2/js/test/openai-client-dispose.test.ts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 297bc539-5f7f-4a70-9411-48e91a5bf532
Only the disposal suite should treat unavailable CI catalog data as an environmental skip. Keep every other real-model suite's existing fail-fast behavior instead of globally converting model-selection failures into SkipFixture.

Files changed:

- sdk_v2/js/test/_fixtures/realModelManager.ts

- sdk_v2/js/test/openai-client-dispose.test.ts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 297bc539-5f7f-4a70-9411-48e91a5bf532
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