Skip to content

Commit 7562ad2

Browse files
authored
chore(deps): bump napi (#600)
1 parent 3e58a6a commit 7562ad2

File tree

4 files changed

+116
-93
lines changed

4 files changed

+116
-93
lines changed

napi/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ doctest = false
2222
[dependencies]
2323
oxc_resolver = { workspace = true }
2424

25-
napi = { version = "3.0.0-beta.11", default-features = false, features = ["napi3", "serde-json"] }
26-
napi-derive = { version = "3.0.0-beta.11" }
25+
napi = { version = "3.0.0-beta", default-features = false, features = ["napi3", "serde-json"] }
26+
napi-derive = { version = "3.0.0-beta" }
2727
tracing-subscriber = { version = "0.3.19", optional = true, default-features = false, features = ["std", "fmt"] } # Omit the `regex` feature
2828

2929
[target.'cfg(not(any(target_os = "linux", target_os = "freebsd", target_arch = "arm", target_family = "wasm")))'.dependencies]

napi/resolver.wasi.cjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,29 @@ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule
6565
worker.onmessage = ({ data }) => {
6666
__wasmCreateOnMessageForFsProxy(__nodeFs)(data)
6767
}
68+
69+
// The main thread of Node.js waits for all the active handles before exiting.
70+
// But Rust threads are never waited without `thread::join`.
71+
// So here we hack the code of Node.js to prevent the workers from being referenced (active).
72+
// According to https://github.com/nodejs/node/blob/19e0d472728c79d418b74bddff588bea70a403d0/lib/internal/worker.js#L415,
73+
// a worker is consist of two handles: kPublicPort and kHandle.
74+
{
75+
const kPublicPort = Object.getOwnPropertySymbols(worker).find(s =>
76+
s.toString().includes("kPublicPort")
77+
);
78+
if (kPublicPort) {
79+
worker[kPublicPort].ref = () => {};
80+
}
81+
82+
const kHandle = Object.getOwnPropertySymbols(worker).find(s =>
83+
s.toString().includes("kHandle")
84+
);
85+
if (kPublicPort) {
86+
worker[kHandle].ref = () => {};
87+
}
88+
89+
worker.unref();
90+
}
6891
return worker
6992
},
7093
overwriteImports(importObject) {

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
"napi-postinstall": "^0.3.0"
3232
},
3333
"devDependencies": {
34-
"@napi-rs/cli": "3.0.0-alpha.91",
34+
"@napi-rs/cli": "3.0.0-alpha.92",
3535
"@napi-rs/wasm-runtime": "^0.2.7",
36-
"@types/node": "^24.0.0",
37-
"emnapi": "^1.3.1",
36+
"@types/node": "^24.0.12",
37+
"emnapi": "^1.4.4",
3838
"prettier": "^3.6.2",
3939
"prettier-plugin-pkg": "^0.21.1",
4040
"typescript": "^5.8.2",

0 commit comments

Comments
 (0)