Repository navigation
Commit ff0bd97
authored
Use napi's module retain helper to keep Oxide loaded [ci-all] (#20726)
This PR replaces the Windows-only `GetModuleHandleExW` FFI from
#20471 with the helper
that napi-rs now ships for the same purpose:
`napi::bindgen_prelude::retain_current_module_for_unload_safety()`
(added in napi-rs/napi-rs#3423, released in
3.12.1).
The `#[napi(module_exports)]` hook now calls the helper once. That keeps
the Oxide addon mapped after a Node worker that loaded it exits, so
Rayon threads that outlive the worker don't crash with `0xC0000005`
(#20470).
Changes:
- Bump `napi` from 3.11.0 to 3.16.2 and `napi-derive` from 3.6.0 to
3.7.1.
- Remove our own `unsafe` FFI block.
Behavior changes compared to
#20471:
- The helper is best effort. If pinning fails, `require` no longer
throws. The addon then behaves as it did before the pin existed.
- The helper also pins the module on Linux and macOS (`dladdr` +
`dlopen(RTLD_NOLOAD)`), not only on Windows.
- The helper does not exist on wasm, so the hook is
`#[cfg(not(target_family = "wasm"))]`. The wasm build had no pin before
either.
This is an internal change with no new effect for users, so it has no
changelog fragment.
## Test plan
- `pnpm run build` (includes the wasm build)
- `cargo test -p tailwind-oxide`
- `env -u NODE_ENV pnpm vitest run --root=integrations oxide/workers`
- `[ci-all]` in the title so CI runs
`integrations/oxide/workers.test.ts` on Windows and macOS too.1 parent 0591058 commit ff0bd97
3 files changed
Lines changed: 37 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
| 11 | + | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
9 | 10 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 11 | + | |
| 12 | + | |
38 | 13 | | |
39 | 14 | | |
40 | 15 | | |
| |||
0 commit comments