<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>297134</bug_id>
          
          <creation_ts>2025-08-08 12:28:50 -0700</creation_ts>
          <short_desc>Exception (JS value) thrown inside WebAssembly using WebAssembly.JSTag is wrapped into WebAssembly.Exception immediately</short_desc>
          <delta_ts>2025-08-08 17:52:06 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebAssembly</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>297127</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>bashorov</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2135254</commentid>
    <comment_count>0</comment_count>
    <who name="">bashorov</who>
    <bug_when>2025-08-08 12:28:50 -0700</bug_when>
    <thetext>So as a result, 
1. It&apos;s observable inside a wasm module as an instance of WebAssembly.Exception instead of thrown JS value.
2. It&apos;s not unwrapped when it crosses wasm-js border, so in JS it is also visible as an instance of WebAssembly.Exception instead of thrown JS value.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2135262</commentid>
    <comment_count>1</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2025-08-08 13:26:16 -0700</bug_when>
    <thetext>Thanks! This will be fixed in bug 297127</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2135263</commentid>
    <comment_count>2</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2025-08-08 13:26:21 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 297127 ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2135265</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-08-08 13:27:17 -0700</bug_when>
    <thetext>&lt;rdar://problem/157875232&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2135332</commentid>
    <comment_count>4</comment_count>
    <who name="Keith Miller">keith_miller</who>
    <bug_when>2025-08-08 16:16:34 -0700</bug_when>
    <thetext>Are you sure 2 is the case? https://webassembly.github.io/exception-handling/js-api/#call-an-exported-function says it is unwrapped back to the underlying JS value when propagating back through JS. I&apos;m pretty sure the bug in https://github.com/WebKit/WebKit/pull/49130 was due to the opposite; we weren&apos;t unwrapping the `WebAssembly.Exception` if it had a JSTag for exported functions if it was created and thrown from wasm i.e. `(throw $JSTag someExternref)`

What&apos;s the case you&apos;re seeing 1 in?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2135367</commentid>
    <comment_count>5</comment_count>
    <who name="">bashorov</who>
    <bug_when>2025-08-08 17:43:11 -0700</bug_when>
    <thetext>&gt; we weren&apos;t unwrapping the `WebAssembly.Exception`
(2) is basically saying the same thing</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2135369</commentid>
    <comment_count>6</comment_count>
    <who name="">bashorov</who>
    <bug_when>2025-08-08 17:46:54 -0700</bug_when>
    <thetext>BTW, I don&apos;t see any test for (1) in the PR. Could you please check if it&apos;s fixed?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2135370</commentid>
    <comment_count>7</comment_count>
    <who name="">bashorov</who>
    <bug_when>2025-08-08 17:52:06 -0700</bug_when>
    <thetext>&gt; What&apos;s the case you&apos;re seeing 1 in?

Case: an exception is thrown inside wasm using JSTag and caught with JSTag inside wasm.
Actual: in the catch block, we receive an instance of WebAssembly.Exception wrapping the original JS value, e,g, JS Error.
Expected: in the catch block, we receive the original JS value.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>