<?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>313787</bug_id>
          
          <creation_ts>2026-04-30 16:18:37 -0700</creation_ts>
          <short_desc>Promise resolvers keep the Promise alive even after resolution</short_desc>
          <delta_ts>2026-05-01 17:26:57 -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>JavaScriptCore</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Kevin Gibbons">bakkot</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2206426</commentid>
    <comment_count>0</comment_count>
      <attachid>479406</attachid>
    <who name="Kevin Gibbons">bakkot</who>
    <bug_when>2026-04-30 16:18:37 -0700</bug_when>
    <thetext>Created attachment 479406
repro showing high heap usage even after GC

Once a Promise has resolved, its resolvers become no-ops and should not prevent the Promise from being gc&apos;d, but they do. This is most noticeable when using Promise.race to race a long-pending and a short-pending Promise: the race completes quickly with the value from the short-pending Promise, which is then kept alive until the long-pending Promise completes, because the long-pending Promise holds a resolver for the Promise.race Promise and this bug causes that to keep said Promise alive.

V8 has the same bug which I am in the process of fixing. SpiderMonkey does not. This has been plaguing developers for years, see e.g. https://github.com/nodejs/node/issues/17469 https://x.com/KentonVarda/status/2044935325554823193 etc

I am pretty sure all that&apos;s necessary to fix this is to null out the `JSFunctionWithFields::Field::ResolvingPromise` field on both `callee` and `other` immediate after this bit: https://github.com/WebKit/WebKit/blob/013da9aa8cc1a0e26f5f34408efa118956499193/Source/JavaScriptCore/runtime/JSPromise.cpp#L418-L421

but I haven&apos;t actually confirmed that.

Attachment uses Bun because it exposes the APIs necessary to make this obvious, sorry I don&apos;t have a cleaner repro.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2206741</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2026-05-01 17:26:57 -0700</bug_when>
    <thetext>&lt;rdar://problem/176061996&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>479406</attachid>
            <date>2026-04-30 16:18:37 -0700</date>
            <delta_ts>2026-04-30 16:18:37 -0700</delta_ts>
            <desc>repro showing high heap usage even after GC</desc>
            <filename>promise-for-bun.js</filename>
            <type>text/javascript</type>
            <size>627</size>
            <attacher name="Kevin Gibbons">bakkot</attacher>
            
              <data encoding="base64">aW1wb3J0IHsgaGVhcFN0YXRzIH0gZnJvbSAiYnVuOmpzYyI7CgoKZnVuY3Rpb24gcmFuZG9tU3Ry
aW5nKGxlbmd0aCkgewogIGxldCByZXN1bHQgPSAiIjsKICBjb25zdCBjaGFyYWN0ZXJzID0gIkFC
Q0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXowMTIzNDU2
Nzg5IjsKICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICByZXN1bHQgKz0g
Y2hhcmFjdGVycy5jaGFyQXQoTWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpICogY2hhcmFjdGVycy5s
ZW5ndGgpKTsKICB9CiAgcmV0dXJuIHJlc3VsdDsKfQoKKGFzeW5jIGZ1bmN0aW9uICgpIHsKICBj
b25zdCBwZW5kaW5nID0gbmV3IFByb21pc2UoKCkgPT4ge30pOwogIGZvciAobGV0IGkgPSAwOyBp
IDwgMTAwMDA7IGkrKykgewogICAgYXdhaXQgUHJvbWlzZS5yYWNlKFtwZW5kaW5nLCBQcm9taXNl
LnJlc29sdmUocmFuZG9tU3RyaW5nKDEwMDApKV0pOwogICAgaWYgKGkgJSAxMDAwID09PSAwKSB7
CiAgICAgIGF3YWl0IG5ldyBQcm9taXNlKHJlcyA9PiBzZXRUaW1lb3V0KHJlcywgMTApKTsKICAg
ICAgQnVuLmdjKCk7CiAgICB9CiAgfQogIGNvbnNvbGUubG9nKGhlYXBTdGF0cygpKTsKfSkoKTsK
</data>

          </attachment>
      

    </bug>

</bugzilla>