Skip to content

Commit

Permalink
Patch Promise.constructor differently
Browse files Browse the repository at this point in the history
  • Loading branch information
gzuidhof committed Dec 9, 2024
1 parent 39f2540 commit e90a030
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@friendlycaptcha/sdk",
"version": "0.1.11",
"version": "0.1.12",
"description": "In-browser SDK for Friendly Captcha v2 (currently in preview only)",
"main": "dist/sdk.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion sdktest/test/zone/body.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
</form>
</main>

<script defer src="main.tmpl.ts"></script>
<script defer src="{{ .SiteJSPath }}"></script>
<script defer src="main.tmpl.ts"></script>

10 changes: 6 additions & 4 deletions src/signals/collectStacktrace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,12 @@ export const takeRecords = (function () {
};
queue.push(record);

// Promises are special as we are patching a constructor.
// (Note: if we ever patch non-Promise constructors, we should add a check here).
const v = (hasGetterOrSetter ? descriptor.get : descriptor.value);

// Promises are special as we are patching a constructor. This was added to support zone.js better (used inside
// of Angular).
if (c === prop) {
return Promise.constructor;
return v
}

/**!
Expand All @@ -145,7 +147,7 @@ export const takeRecords = (function () {
* that the error is from other source code deeper in the
* stack trace as FriendlyCaptcha wraps native functions.
*/
return (hasGetterOrSetter ? descriptor.get : descriptor.value).apply(this, args);
return v.apply(this, args);
/**!
* ----------------------
*/
Expand Down

0 comments on commit e90a030

Please sign in to comment.