Skip to content

Patches around async work - #434

Merged
ospfranco merged 2 commits into
mainfrom
oscar/patches-around-async-work
Aug 13, 2026
Merged

Patches around async work#434
ospfranco merged 2 commits into
mainfrom
oscar/patches-around-async-work

Conversation

@ospfranco

@ospfranco ospfranco commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

From discord

we're crashing whenever the JS runtime reloads in a live process (CodePush OTA,
RN 0.81 to 0.85, op-sqlite 16.2.2): ~jsi::Value() on ThreadPool::doWork() and
thread::join failed: Resource deadlock avoided.

Two things look suspect in cpp/: promisify's task captures a shared_ptr
it never uses, so the worker can end up joining itself, and the success path
re-captures only resolve, so reject gets destroyed on the pool thread every
query. doWork() also decrements busy before destroying the task, so
waitFinished() and close() can return early.

This seem to be indeed valid findings:

  • The thread pool does not need to be captured, as it will try to join itself on it's destructor. Likely an remnant when I was writing this abstractions by hand
  • The reject needs to be captured in the lambda so it can safely destroyed in the JS thread
  • The task needs to be cleared before the busy counter goes down so it resources can be properly cleaned up

@ospfranco
ospfranco force-pushed the oscar/patches-around-async-work branch from 11e25d9 to efdda6e Compare August 12, 2026 23:01
@ospfranco
ospfranco merged commit 460a28e into main Aug 13, 2026
10 checks passed
@ospfranco
ospfranco deleted the oscar/patches-around-async-work branch August 13, 2026 11:28
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