diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2021-09-08 22:14:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-08 23:14:26 +0200 |
commit | d9476292929a680e364db403d6fc69cfb893599f (patch) | |
tree | 49e6a78f550232bf6175e6232ecbc96a107b06c4 /ext/web/01_dom_exception.js | |
parent | b31dad89a6090216361275e3cc310d10216cae65 (diff) |
fix(ext/web): Preserve stack traces for DOMExceptions (#11959)
Diffstat (limited to 'ext/web/01_dom_exception.js')
-rw-r--r-- | ext/web/01_dom_exception.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ext/web/01_dom_exception.js b/ext/web/01_dom_exception.js index c6f60ae2f..0d9e82c56 100644 --- a/ext/web/01_dom_exception.js +++ b/ext/web/01_dom_exception.js @@ -11,6 +11,8 @@ ((window) => { const { + ArrayPrototypeSlice, + Error, ErrorPrototype, ObjectDefineProperty, ObjectEntries, @@ -94,6 +96,16 @@ context: "Argument 2", }); this.#code = nameToCodeMapping[this.#name] ?? 0; + + // `DOMException` does not have `.stack`, so `Error.prepareStackTrace()` + // is not called on it, meaning our structured stack trace hack doesn't + // apply. This patches it in. + const error = new Error(); + error.stack; + ObjectDefineProperty(this, "__callSiteEvals", { + value: ArrayPrototypeSlice(error.__callSiteEvals, 1), + configurable: true, + }); } get message() { |