Commit 77a3c0b
authored
Handle the FinalizationRegistry's context in
Each FinalizationRegistry object has a context associated with it, which was the
context at its construction. This context is used for calling its callback when
any registered object is GC'd, which takes place in the
`CleanupFinalizationRegistry` AO.
In the current spec, `CleanupFinalizationRegistry` handles the swapping of this
context, and restores it back at the end. This, however, causes a problem for
hosts that report uncaught JS exceptions by running JS code (such as the
`"error"` event on `window` in the web, or the `"unhandledException"` event on
`process` in Node.js), since they should run this event in the
FinalizationRegistry's creation context, but `CleanupFinalizationRegistry` exits
that context before the end of the function.
Since `CleanupFinalizationRegistry` (and
`HostEnqueueFinalizationRegistryCleanupJob`) only clean up a single
FinalizationRegitry, however, the context swapping can be pushed to the host
hook instead, with the step about host-defined error reporting being inside that
context. This ensures that such error reporting events are fired in the right
context.HostEnqueueFinalizationRegistryCleanupJob (#111)1 parent 67e7074 commit 77a3c0b
1 file changed
+25
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
155 | 158 | | |
156 | 159 | | |
157 | 160 | | |
| |||
0 commit comments