Skip to content

Commit 9bc94cc

Browse files
authored
chore: add napi::tokio_runtime::block_on (#12358)
* chore: add napi::tokio_runtime::block_on * chore: add allow to exist code
1 parent 5c4b597 commit 9bc94cc

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

clippy.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ disallowed-methods = [
1212
{ path = "std::mem::forget", reason = "future::scope is unsafe when used with forget" },
1313
{ path = "futures::executor::block_on", reason = "block_on can cause deadlock easily" },
1414
{ path = "async_std::task::block_on", reason = "block_on can cause deadlock easily" },
15-
{ path = "pollster::block_on", reason = "block_on can cause deadlock easily" }
15+
{ path = "pollster::block_on", reason = "block_on can cause deadlock easily" },
16+
{ path = "napi::tokio_runtime::block_on", reason = "block_on can cause deadlock easily" }
1617
]

crates/rspack_binding_api/src/fs_node/write.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ impl ReadableFileSystem for NodeFileSystem {
188188
}
189189
#[instrument(skip(self), level = "debug")]
190190
fn read_sync(&self, path: &Utf8Path) -> Result<Vec<u8>> {
191+
#[allow(clippy::disallowed_methods)]
191192
block_on(self.read(path))
192193
}
193194

@@ -210,6 +211,7 @@ impl ReadableFileSystem for NodeFileSystem {
210211

211212
#[instrument(skip(self), level = "debug")]
212213
fn metadata_sync(&self, path: &Utf8Path) -> Result<FileMetadata> {
214+
#[allow(clippy::disallowed_methods)]
213215
block_on(self.metadata(path))
214216
}
215217

@@ -265,6 +267,7 @@ impl ReadableFileSystem for NodeFileSystem {
265267
}
266268
#[instrument(skip(self), level = "debug")]
267269
fn read_dir_sync(&self, dir: &Utf8Path) -> Result<Vec<String>> {
270+
#[allow(clippy::disallowed_methods)]
268271
block_on(ReadableFileSystem::read_dir(self, dir))
269272
}
270273
#[instrument(skip(self), level = "debug")]

crates/rspack_binding_api/src/resolver.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ impl JsResolver {
5353
impl JsResolver {
5454
#[napi]
5555
pub fn resolve_sync(&self, path: String, request: String) -> napi::Result<Either<String, ()>> {
56+
#[allow(clippy::disallowed_methods)]
5657
block_on(async {
5758
match self.resolver.resolve(Path::new(&path), &request).await {
5859
Ok(rspack_core::ResolveResult::Resource(resource)) => Ok(Either::A(resource.full_path())),

0 commit comments

Comments
 (0)