summaryrefslogtreecommitdiff
path: root/core/runtime.rs
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2022-03-19 15:59:44 +0100
committerGitHub <noreply@github.com>2022-03-19 15:59:44 +0100
commit52459faf0b35ed157bb640d24c6107e1ff00aded (patch)
tree1ff10d2d4188861e4b4aafd3d92f562ce6c1fdb0 /core/runtime.rs
parent52a6e9ef4ad63c06504867d60a44840c62b7a0cd (diff)
fix(ops): throw TypeError on op return failure (#14033)
Fixes #14028
Diffstat (limited to 'core/runtime.rs')
-rw-r--r--core/runtime.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/core/runtime.rs b/core/runtime.rs
index 6ca586997..5b6ce3998 100644
--- a/core/runtime.rs
+++ b/core/runtime.rs
@@ -2854,4 +2854,24 @@ assertEquals(1, notify_return_value);
assert_eq!(2, PROMISE_REJECT.load(Ordering::Relaxed));
assert_eq!(2, UNCAUGHT_EXCEPTION.load(Ordering::Relaxed));
}
+
+ #[test]
+ fn test_op_return_serde_v8_error() {
+ #[op]
+ fn op_err() -> Result<std::collections::BTreeMap<u64, u64>, anyhow::Error> {
+ Ok([(1, 2), (3, 4)].into_iter().collect()) // Maps can't have non-string keys in serde_v8
+ }
+
+ let ext = Extension::builder().ops(vec![op_err::decl()]).build();
+ let mut runtime = JsRuntime::new(RuntimeOptions {
+ extensions: vec![ext],
+ ..Default::default()
+ });
+ assert!(runtime
+ .execute_script(
+ "test_op_return_serde_v8_error.js",
+ "Deno.core.opSync('op_err')"
+ )
+ .is_err());
+ }
}