handleSerialError fails when setting err.routerCode with TypeError(s)
Fetch network requests or other fetch errors that don't even bring a response are automatically TypeError, and that object can't be extended, causing: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_define_property_object_not_extensible
MDN Web Docs
TypeError: can't define property "x": "obj" is not extensible - Jav...
The JavaScript exception "can't define property "x": "obj" is not extensible" occurs
when Object.preventExtensions() marked an object as no longer extensible,
so that it will never have properties beyond the ones it had at the time it was marked
as non-extensible.
3 Replies
evident-indigoOP•12mo ago
Fetch network requests or other fetch errors that don't even bring a response are automatically TypeError, and that object can't be extended, causing: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_define_property_object_not_extensible
MDN Web Docs
TypeError: can't define property "x": "obj" is not extensible - Jav...
The JavaScript exception "can't define property "x": "obj" is not extensible" occurs
when Object.preventExtensions() marked an object as no longer extensible,
so that it will never have properties beyond the ones it had at the time it was marked
as non-extensible.
evident-indigoOP•12mo ago
The solution is to wrap fetch network/cors errors into your own, e.g.:
However this feels like an imposition on the router part just because err.routerCode is being set by the error handler. Perhaps a warning would be helfpul.
harsh-harlequin•12mo ago
can you please provide a minimal example for this ?