Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0a9980b

Browse filesBrowse files
authored
fix(napi): JsObjectValue::get_property signature (#2628)
* fix(napi): JsObjectValue::get_property signature * debug
1 parent 6548414 commit 0a9980b
Copy full SHA for 0a9980b

File tree

2 files changed

+14
-14
lines changed
Filter options

2 files changed

+14
-14
lines changed

‎.github/workflows/test-release.yaml

Copy file name to clipboardExpand all lines: .github/workflows/test-release.yaml
+1-12Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ jobs:
7171
build: yarn build:test
7272
test: |
7373
yarn test:cli
74-
ulimit -c unlimited
75-
sudo yarn test
74+
DEBUG="*" yarn test
7675
yarn tsc -p examples/napi/tsconfig.json --noEmit --skipLibCheck
7776
yarn test:macro
7877
toolchain: stable
@@ -206,16 +205,6 @@ jobs:
206205
NODE_OPTIONS: '--max-old-space-size=8192'
207206
DISABLE_V8_COMPILE_CACHE: 1
208207

209-
- name: chmod core files
210-
if: ${{ failure() && matrix.settings.target == 'x86_64-unknown-linux-gnu' }}
211-
run: sudo chmod -R +rwx /cores/*
212-
213-
- uses: actions/upload-artifact@v4
214-
if: ${{ failure() }}
215-
with:
216-
name: crashes
217-
path: /cores
218-
219208
- name: Electron tests
220209
if: matrix.settings.target == 'aarch64-apple-darwin' || matrix.settings.target == 'x86_64-pc-windows-msvc'
221210
run: |

‎crates/napi/src/js_values/mod.rs

Copy file name to clipboardExpand all lines: crates/napi/src/js_values/mod.rs
+13-2Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,25 @@ pub trait JsObjectValue<'env>: JsValue<'env> {
249249

250250
fn get_property<'k, K, T>(&self, key: K) -> Result<T>
251251
where
252-
K: JsObjectValue<'k>,
253-
T: FromNapiValue,
252+
K: JsValue<'k>,
253+
T: FromNapiValue + ValidateNapiValue,
254254
{
255255
let mut raw_value = ptr::null_mut();
256256
let env = self.value().env;
257257
check_status!(unsafe {
258258
sys::napi_get_property(env, self.value().value, key.raw(), &mut raw_value)
259259
})?;
260+
unsafe { T::validate(env, raw_value) }.map_err(|mut err| {
261+
err.reason = format!(
262+
"Object property '{:?}' type mismatch. {}",
263+
key
264+
.coerce_to_string()
265+
.and_then(|s| s.into_utf8())
266+
.and_then(|s| s.into_owned()),
267+
err.reason
268+
);
269+
err
270+
})?;
260271
unsafe { T::from_napi_value(env, raw_value) }
261272
}
262273

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.