mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
refactor(core): return better error for non-existent async ops (#18772)
This commit is contained in:
parent
36cfb2fdbb
commit
5a77bb8844
2 changed files with 22 additions and 0 deletions
|
@ -20,6 +20,7 @@
|
|||
PromisePrototypeThen,
|
||||
RangeError,
|
||||
ReferenceError,
|
||||
ReflectHas,
|
||||
SafeArrayIterator,
|
||||
SafeMap,
|
||||
SafePromisePrototypeFinally,
|
||||
|
@ -235,6 +236,9 @@
|
|||
} catch (err) {
|
||||
// Cleanup the just-created promise
|
||||
getPromise(id);
|
||||
if (!ReflectHas(ops, name)) {
|
||||
throw new TypeError(`${name} is not a registered op`);
|
||||
}
|
||||
// Rethrow the error
|
||||
throw err;
|
||||
}
|
||||
|
@ -257,6 +261,9 @@
|
|||
} catch (err) {
|
||||
// Cleanup the just-created promise
|
||||
getPromise(id);
|
||||
if (!ReflectHas(ops, name)) {
|
||||
throw new TypeError(`${name} is not a registered op`);
|
||||
}
|
||||
// Rethrow the error
|
||||
throw err;
|
||||
}
|
||||
|
|
|
@ -4644,6 +4644,21 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_non_existent_async_op_error() {
|
||||
// Verify that "resizable ArrayBuffer" is disabled
|
||||
let mut runtime = JsRuntime::new(Default::default());
|
||||
let err = runtime
|
||||
.execute_script_static(
|
||||
"test_rab.js",
|
||||
r#"Deno.core.opAsync("this_op_doesnt_exist");"#,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert!(err
|
||||
.to_string()
|
||||
.contains("this_op_doesnt_exist is not a registered op"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn cant_load_internal_module_when_snapshot_is_loaded_and_not_snapshotting(
|
||||
) {
|
||||
|
|
Loading…
Add table
Reference in a new issue