Skip to content

fix(pouchdb-errors): guard Error.stack access when stack is inaccessible#9193

Open
Mayankaggarwal8055 wants to merge 7 commits intoapache:masterfrom
Mayankaggarwal8055:fix/error-stack-handling
Open

fix(pouchdb-errors): guard Error.stack access when stack is inaccessible#9193
Mayankaggarwal8055 wants to merge 7 commits intoapache:masterfrom
Mayankaggarwal8055:fix/error-stack-handling

Conversation

@Mayankaggarwal8055
Copy link
Copy Markdown

@Mayankaggarwal8055 Mayankaggarwal8055 commented Mar 5, 2026

What does this PR do?

Fixes error handling in pouchdb-errors by safely accessing Error.stack using try/catch.

What issue does this PR fix?

Fixes #9067

Testing

  • Verified locally
  • Ensured no crashes when Error.stack is inaccessible

Checklist

  • Code builds correctly
  • Tests pass
  • Changes are minimal and safe

@Mayankaggarwal8055
Copy link
Copy Markdown
Author

The current codebase does not define CustomPouchError, so only the stack-safety change from the reported patch was applicable.

@Mayankaggarwal8055 Mayankaggarwal8055 force-pushed the fix/error-stack-handling branch from 57e1780 to f6fe588 Compare March 5, 2026 15:17
@Mayankaggarwal8055 Mayankaggarwal8055 force-pushed the fix/error-stack-handling branch from 1918749 to acc8cb1 Compare March 6, 2026 08:24
@Mayankaggarwal8055
Copy link
Copy Markdown
Author

Hey @janl , could you please take a look at this when you get a moment?

I’ve implemented the fix for handling Error.stack safely by wrapping it in a try/catch to avoid crashes in restricted environments. The change is minimal and keeps the existing behavior intact while making it more robust.

Everything is working fine locally, and the fix directly addresses the issue discussed. Would really appreciate your feedback or any suggestions for improvement.

Thanks! 🙌

Comment thread packages/node_modules/pouchdb-errors/src/index.js Outdated
Comment thread packages/node_modules/pouchdb-errors/src/index.js Outdated
Comment thread packages/node_modules/pouchdb-errors/src/index.js
Mayankaggarwal8055 and others added 3 commits April 7, 2026 13:37
Co-authored-by: Steven <SourceR85@users.noreply.github.com>
Co-authored-by: Steven <SourceR85@users.noreply.github.com>
@SourceR85 SourceR85 dismissed their stale review April 7, 2026 08:19

Requested changes now applied

Safely handle stack assignment with fallback message.
@SourceR85
Copy link
Copy Markdown
Contributor

Should be fine.
Someone else needs to review, since I was involved too much and did 3 things at the time during this review/refinement.

@janl
Copy link
Copy Markdown
Member

janl commented Apr 14, 2026

can you please reinstate our PR template and fill it out accordingly?

@Mayankaggarwal8055
Copy link
Copy Markdown
Author

Hi @janl,

I’ve updated the PR description to match the required template.

The fix is minimal and all checks are passing. Could you please take another look when you have time?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix error handling in pouchdb-errors to prevent crashes when Error.stack is inaccessible

3 participants