Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix max int generation on web to use -1 >> 0 #661

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

a-h-mzd
Copy link

@a-h-mzd a-h-mzd commented Nov 5, 2024

What and why?

When running flutter apps compiled to JS, 1 << 32 results in 0 instead of the max int allowed for random number generation.

How?

According to this we can use -1 >> 0 to achieve what is needed.

Review checklist

  • This pull request has appropriate unit and / or integration tests
  • This pull request references a Github or JIRA issue

@a-h-mzd a-h-mzd requested a review from a team as a code owner November 5, 2024 13:46
@fuzzybinary
Copy link
Member

Hi @a-h-mzd ,

Thanks for taking the time to create a PR.

Are you seeing something behave incorrectly? I'm pretty sure this tracer is actually only used in native platforms, not in Web where we rely on the Datadog Browser SDK's tracing implementation.

@a-h-mzd
Copy link
Author

a-h-mzd commented Nov 5, 2024

@fuzzybinary thank you for the quick response.

TracingContext.generateTracingContext is actually used by the plugins(like datadog_gql_link and datadog_grpc_interceptor). I have also created a new package which contains an interceptor for Dio based on the implementation found in datadog_gql_link. I will create a PR for it soon.

@fuzzybinary
Copy link
Member

👍 I'll still have to double check that the Browser SDK doesn't handle those calls internally anyway. It would be better if we had a failing test or repro case to work from to start.

@a-h-mzd
Copy link
Author

a-h-mzd commented Nov 5, 2024

It’s actually pretty easy to test. Just try to print 1 << 32 and run the code in the browser or just compile it to JS. You’ll see that 1 << 32 is converted to 0.

@fuzzybinary
Copy link
Member

Yes, I'm more referring to showing that using the grpc or gql interceptors on web does not produce the desired results. The actual feature is that distributed tracing in these packages works on web. 1 << 32 is an implementation detail and the cause of the bug.

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.

2 participants