diff --git a/src/bindings/mod.rs b/src/bindings/mod.rs index 86eab4f..384ba3d 100644 --- a/src/bindings/mod.rs +++ b/src/bindings/mod.rs @@ -572,7 +572,15 @@ impl ContextWrapper { let res_val = global.property_require("__promiseResult")?; if res_val.is_bool() { let ok = res_val.to_bool()?; - let value = global.property_require("__promiseValue")?; + let value = global.property("__promiseValue")?.unwrap_or_else(|| { + OwnedJsValue::new( + self, + q::JSValue { + u: q::JSValueUnion { int32: 0 }, + tag: TAG_UNDEFINED, + }, + ) + }); if ok { return self.resolve_value(value); diff --git a/src/tests.rs b/src/tests.rs index 00b5a4e..24c30c8 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -622,3 +622,9 @@ fn test_global_setter() { ctx.set_global("a", "a").unwrap(); ctx.eval("a + 1").unwrap(); } + +#[test] +fn test_async_fn_returning_undefined() { + let ctx = Context::new().unwrap(); + ctx.eval("(async () => undefined)()").unwrap(); +} \ No newline at end of file