Skip to content

Commit

Permalink
Fix DataCloneError's by preventing known unclonable values (will be…
Browse files Browse the repository at this point in the history
…… … send as string instead) (#224)

* Fix `DataCloneError`'s by preventing known unclonable values (will be send as string instead)

* Fix unit test
  • Loading branch information
kungfooman authored Nov 16, 2024
1 parent b6e093a commit 199ff37
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src-runtime/inspectType.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ function inspectType(value, expect, loc, name, critical = true) {
crossContextPostMessage({type: 'rti', action: 'deleteBreakpoint', destination: 'ui', key});
}
// Nytaralyxe: options.warns where each warn callback supports one system (node, div/dom etc.)
// Don't post something that can't be transmitted cross-context, so we just stringify it.
// See https://github.com/kungfooman/RuntimeTypeInspector.js/issues/223
if (value instanceof Function) {
value += "";
}
crossContextPostMessage({type: 'rti', action: 'addError', destination: 'ui', value, expect, loc, name, valueToString, strings, extras, key});
}
return ret;
Expand Down
4 changes: 4 additions & 0 deletions test/convert-first/test-typeof.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ class TestClass2 {
function callNew(someClass, ...args) {
return new someClass(...args);
}
options.count = 0;
const testClass1 = callNew(TestClass1, "hoi1");
console.assert(options.count === 0, "Should have 0 errors here");
const testClass2 = callNew(TestClass2, "hoi2");
console.assert(options.count === 1, "Should have 1 error here");
if (options.count === 1) {
console.log("SUCCESS!");
}

0 comments on commit 199ff37

Please sign in to comment.