Skip to content

Commit 5259cbe

Browse files
committed
fixup! use stack trace
1 parent 832efd8 commit 5259cbe

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

lib/internal/abort_controller.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// in https://github.com/mysticatea/abort-controller (MIT license)
55

66
const {
7+
ErrorCaptureStackTrace,
78
ObjectAssign,
89
ObjectDefineProperties,
910
ObjectSetPrototypeOf,
@@ -30,7 +31,6 @@ const {
3031
customInspectSymbol,
3132
kEmptyObject,
3233
kEnumerableProperty,
33-
SideEffectFreeRegExpPrototypeSymbolReplace,
3434
} = require('internal/util');
3535
const { inspect } = require('internal/util/inspect');
3636
const {
@@ -70,8 +70,6 @@ let defaultDOMException;
7070
// because otherwise we'll end up with a require cycle that ends up with
7171
// an incomplete initialization of abort_controller.
7272

73-
const userModuleRegExp = /^ {4}at (?:[^/\\(]+ \()(?!node:(.+):\d+:\d+\)$).*/gm;
74-
7573
function lazyMessageChannel() {
7674
_MessageChannel ??= require('internal/worker/io').MessageChannel;
7775
return new _MessageChannel();
@@ -90,11 +88,9 @@ function lazyDOMException() {
9088

9189
defaultDOMException = new DOMException('This operation was aborted', 'AbortError');
9290

93-
// Avoid V8 leak and remove userland stackstrace
94-
defaultDOMException.stack = SideEffectFreeRegExpPrototypeSymbolReplace(
95-
userModuleRegExp,
96-
defaultDOMException.stack,
97-
'');
91+
// Avoid V8 leak
92+
// eslint-disable-next-line no-unused-vars
93+
const dummy = defaultDOMException.stack;
9894
return defaultDOMException;
9995
}
10096

@@ -185,9 +181,10 @@ class AbortSignal extends EventTarget {
185181
* @param {any} [reason]
186182
* @returns {AbortSignal}
187183
*/
188-
static abort(reason) {
184+
static abort(reason = undefined) {
189185
if (reason === undefined) {
190186
reason = lazyDOMException();
187+
ErrorCaptureStackTrace(reason);
191188
}
192189
return createAbortSignal({ aborted: true, reason });
193190
}
@@ -352,6 +349,7 @@ class AbortController {
352349
abort(reason) {
353350
if (reason === undefined) {
354351
reason = lazyDOMException();
352+
ErrorCaptureStackTrace(reason);
355353
}
356354
abortSignal(this.#signal ??= createAbortSignal(), reason);
357355
}

0 commit comments

Comments
 (0)