Skip to content

feat(android): Add nativeStackAndroid support to NativeLinkedErrors#6278

Open
lucas-zimerman wants to merge 4 commits into
mainfrom
lz/nativeStackAndroid
Open

feat(android): Add nativeStackAndroid support to NativeLinkedErrors#6278
lucas-zimerman wants to merge 4 commits into
mainfrom
lz/nativeStackAndroid

Conversation

@lucas-zimerman

@lucas-zimerman lucas-zimerman commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Captures the JVM stack trace attached to rejected native module promises as a linked exception, so the Java cause of a rejected promise is reported alongside the JS error.

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Android Promise rejections were previously captured by Sentry, but lacked stacktrace on it.

💡 Motivation and Context

To close #3257

💚 How did you test it?

Locally with addition of promise rejection button on sample app

Before

https://sentry-sdks.sentry.io/issues/7547068866
image

After
https://sentry-sdks.sentry.io/issues/7547000366
image

📝 Checklist

  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing
  • No breaking changes

🔮 Next steps

Close #3257

Captures the JVM stack trace attached to rejected native module promises
as a linked exception, so the Java cause of a rejected promise is reported
alongside the JS error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • feat(android): Add nativeStackAndroid support to NativeLinkedErrors by lucas-zimerman in #6278
  • docs(replay): clarify fast renderer option docs by leohara in #6276
  • feat(core): Warn when multiple versions of Sentry JS SDK are detected by antonis in #6269

🤖 This preview updates automatically when you update the PR.

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor
Fails
🚫 Pull request is not ready for merge, please add the "ready-to-merge" label to the pull request
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against f9305ae

@lucas-zimerman lucas-zimerman marked this pull request as ready for review June 12, 2026 17:47
Comment on lines +58 to +60
if (nativeStackAndroidException && linkedErrors.length + 1 < limit) {
linkedErrors.push(nativeStackAndroidException);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The limit check linkedErrors.length + 1 < limit is an off-by-one error. It incorrectly prevents adding the final nativeStackAndroid exception when the cause chain is at maximum depth.
Severity: LOW

Suggested Fix

Change the condition linkedErrors.length + 1 < limit to linkedErrors.length < limit. This will correctly allow adding one more exception, up to the specified limit.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/core/src/js/integrations/nativelinkederrors.ts#L58-L60

Potential issue: An off-by-one error exists in the limit check for linked errors. The
condition `linkedErrors.length + 1 < limit` prevents adding the `nativeStackAndroid`
exception when the `cause` chain already contains `limit - 1` items. In this scenario,
the check evaluates to `limit < limit`, which is false, causing the native exception to
be silently dropped even though adding it would not exceed the `limit`. This results in
incomplete error data when the exception chain is exactly at the maximum allowed depth.

Did we get this right? 👍 / 👎 to inform future reviews.

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.

Add support for nativeStackAndroid for user rejected Android Promises

1 participant