Skip to content

Promise.race implementation changes behavior when used with non-promises #1318

Closed
@aaemnnosttv

Description

@aaemnnosttv

Description

When the browser agent is loaded, Promise.race behaves differently when called with a non-promise.

This is a valid use of the function and can be used to inspect the status of a promise as documented here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race#using_promise.race_to_detect_the_status_of_a_promise

Using this technique with the browser agent loaded results in Promises always evaluating to be pending, even when they are fulfilled.

This is easily testable in the browser as can be seen below.

Steps to Reproduce

image

When NRBA is loaded, Promise.race returns the first non-promise, even when a resolved promise is before it.

Expected Behavior

image

Promise.race should return the first fulfilled promise, even if followed by a non-promise.

A non-promise can still "beat" a promise in the race though. Essentially, resolved promises should be equal with non-promises, with the first one in the list winning.

image

Relevant Logs / Console output

See above

Your Environment

  • Google Chrome Version 131.0.6778.265 (Official Build) (x86_64)
  • MacOS 15.2
  • Browser agent version 1.128.2
  • APM language and version, if applicable (e.g., Dotnet 10.2.0), and auto|manual

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions