@@ -47,6 +47,13 @@ const {
4747 Serializer,
4848 Deserializer,
4949} = internalBinding ( 'serdes' ) ;
50+ const {
51+ DOMException,
52+ } = internalBinding ( 'messaging' ) ;
53+ const {
54+ messaging_clone_symbol,
55+ messaging_deserialize_symbol,
56+ } = internalBinding ( 'symbols' ) ;
5057const {
5158 namespace : startupSnapshot ,
5259} = require ( 'internal/v8/startup_snapshot' ) ;
@@ -381,6 +388,8 @@ function arrayBufferViewIndexToType(index) {
381388 return undefined ;
382389}
383390
391+ const kDOMExceptionHostObjectTag = 14 ;
392+
384393class DefaultSerializer extends Serializer {
385394 constructor ( ) {
386395 super ( ) ;
@@ -395,6 +404,14 @@ class DefaultSerializer extends Serializer {
395404 * @returns {void }
396405 */
397406 _writeHostObject ( abView ) {
407+ // Route DOMException through the same hooks used by structuredClone
408+ if ( abView instanceof DOMException ) {
409+ const { data } = abView [ messaging_clone_symbol ] ( ) ;
410+ this . writeUint32 ( kDOMExceptionHostObjectTag ) ;
411+ this . writeValue ( data ) ;
412+ return ;
413+ }
414+
398415 // Keep track of how to handle different ArrayBufferViews. The default
399416 // Serializer for Node does not use the V8 methods for serializing those
400417 // objects because Node's `Buffer` objects use pooled allocation in many
@@ -426,6 +443,14 @@ class DefaultDeserializer extends Deserializer {
426443 */
427444 _readHostObject ( ) {
428445 const typeIndex = this . readUint32 ( ) ;
446+ // Route DOMException through the same hooks used by structuredClone
447+ if ( typeIndex === kDOMExceptionHostObjectTag ) {
448+ const data = this . readValue ( ) ;
449+ const domException = new DOMException ( ) ;
450+ domException [ messaging_deserialize_symbol ] ( data ) ;
451+ return domException ;
452+ }
453+
429454 const ctor = arrayBufferViewIndexToType ( typeIndex ) ;
430455 const byteLength = this . readUint32 ( ) ;
431456 const byteOffset = this . _readRawBytes ( byteLength ) ;
0 commit comments