Skip to content

fix(pre-init): put unresolved method path on stackTrace - #1297

Open
rmi22186 wants to merge 1 commit into
developmentfrom
fix/preinit-method-path-stacktrace
Open

fix(pre-init): put unresolved method path on stackTrace#1297
rmi22186 wants to merge 1 commit into
developmentfrom
fix/preinit-method-path-stacktrace

Conversation

@rmi22186

Copy link
Copy Markdown
Member

Summary

  • When a pre-init ready-queue method fails to resolve, put the method path on the error stack (e.g. mParticle pre-init method not found: Identity.login) and forward it via stackTrace from identityApiClient so Datadog can query it.
  • Keep the error message low-cardinality (Unable to compute proper mParticle function - method not found) so existing monitors still match the shared prefix.
  • Separate unresolved methods from resolved methods that throw, so those two failure modes are no longer collapsed into the same TypeError-from-.apply shape.

Why

~947k of the recent IDENTITY_REQUEST / Unable to compute proper mParticle function errors were single-wrap failures where Datadog could not show which queued method failed (StackTrace: null, no method in the message). Partner investigation (Wingstop) showed the high-volume case was largely the pre-2.73.0 item-mutation bug reading an argument as the method name — but without a method path on the report we could not confirm that from telemetry alone.

Test plan

  • Jest: unresolved method throws the new message
  • Jest: method path is present on error.stack
  • Jest: resolved method that throws still uses the existing wrapper message
  • Jest: non-function property treated as unresolved
  • npm run lint
  • After merge/deploy: Datadog @errorInfo.StackTrace (or equivalent) contains mParticle pre-init method not found: <path> for unresolved methods
  • Confirm existing monitors on Unable to compute proper mParticle function still match the new - method not found suffix

Keep the error message low-cardinality for monitors, and forward
err.stack so Datadog can show which queued method failed to resolve.
Also separate "method not found" from "resolved method threw".
@rmi22186
rmi22186 requested a review from a team as a code owner July 28, 2026 18:20
@cursor

cursor Bot commented Jul 28, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Changes are limited to pre-init queue error handling and identity error reporting metadata; no auth or API behavior changes.

Overview
Improves observability when the pre-init ready queue cannot resolve a dotted method (e.g. Identity.login): failures now throw a stable, low-cardinality message (Unable to compute proper mParticle function - method not found) while the queued method path is recorded on the error stack (mParticle pre-init method not found: <path>). Resolution uses optional chaining and an explicit function check, so missing namespaces no longer show up as incidental TypeErrors, and that case is separate from a method that resolved but threw during execution.

Identity request error reporting now includes stackTrace from the caught error so Datadog (and similar) can query stack content instead of seeing StackTrace: null for wrapped pre-init failures.

Jest coverage was expanded for stack content, resolved-vs-unresolved failures, and non-function properties treated as unresolved.

Reviewed by Cursor Bugbot for commit ac53dd8. Bugbot is set up for automated code reviews on this repo. Configure here.

@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant