Skip to content

Fix DataCloneError's by preventing known unclonable values (will be… … send as string instead) #224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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!");
}