sentry-dart
sentry-dart copied to clipboard
Sentry SDK throws with dart compile js - cannot parse DSN (likely Flutter Web too)
Platform
Dart Web
Obfuscation
Disabled
Debug Info
Disabled
Doctor
dart info
If providing this information as part of reporting a bug, please review the information
below to ensure it only contains things you're comfortable posting publicly.
#### General info
- Dart 3.2.6 (stable) (Wed Jan 24 13:41:58 2024 +0000) on "linux_x64"
- on linux / Linux 6.7.5-200.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Feb 17 17:20:08 UTC 2024
- locale is en_US.UTF-8
#### Project info
- sdk constraint: '>=2.17.0 <4.0.0'
- dependencies: sentry, web
- dev_dependencies: build_runner, build_web_compilers, lints
#### Process info
| Memory | CPU | Elapsed time | Command line |
| -----: | ---: | -----------: | ------------------------------------------------------------------------------- |
| 479 MB | 0.8% | 37:16 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.82.0 |
| 487 MB | 2.9% | 06:51 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.82.0 |
Version
7.16.1
Steps to Reproduce
Follow recommended sentry setup, provide a DSN to it that looks like:
https://[email protected]/0000000
Make sure that dart2js is set to O0 (Oh, zero) optimization level (other options don't seem to affect the output).
I've done this via build.yaml
targets:
$default:
builders:
build_web_compilers|dart_source_cleanup:
release_options:
enabled: false
build_web_compilers:entrypoint:
options:
dart2js_args:
- -O0
# - --minify
# - --fast-startup
Run the app with either webdev or build_runner.
dart run build_runner serve -r # or webdev serve -r
Expected Result
App to compile and run without errors.
:exclamation: NOTE: other optimization levels, -O1, -O2, -O3 and -O4 all seem to generate proper output and there is NO error
Actual Result
The following exception is thrown:
js_helper.dart:1196 Uncaught TypeError: J.getInterceptor$asx(...).get$length is not a function
at Object.get$length$asx (main.dart.js:669:45)
at Object.Dsn_Dsn$parse (dsn.dart:54:31)
at sentry.dart:253:9
at _wrapJsFunctionForAsync_closure.$protected (async_patch.dart:307:19)
at _wrapJsFunctionForAsync_closure.call$2 (async_patch.dart:332:23)
at Object._asyncStartSync (async_patch.dart:237:3)
at Object.Sentry__setDefaultConfiguration$body (sentry.dart:247:5)
at Object.Sentry__setDefaultConfiguration (sentry.dart:247:5)
at sentry.dart:123:15
at _wrapJsFunctionForAsync_closure.$protected (async_patch.dart:307:19)
This is likely NOT a sentry issue but an SDK one. I do believe this also affects Flutter Web.
Minimum repro code
void main() {
var uri = Uri.parse('https://[email protected]/0000000');
print('${uri.pathSegments.isEmpty}'); // dsn.dart:54 contains a similar expression
}
Run the above code with dart run build_runner serve web -r with -O0 in build.yaml.
The @ character is much disliked by -O0.
Are you willing to submit a PR?
Yes
This is likely relevant: https://github.com/dart-lang/sdk/issues/55058
interesting edge case, thx for the deep dive! I'd assume this is blocked by the dart issue?
Correct. Someone one the Dart team said they would look at it.
What do you guys usually do in these situations? Update docs eg. or wait for fix?
In that case we would add it to our troubleshooting docs: https://docs.sentry.io/platforms/flutter/troubleshooting/
If you like you can also open up a PR for the site :) https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/flutter/troubleshooting.mdx
it should be fine to document it there, we unfortunately don't have a dart troubleshooting page
Blocked by
- [ ] https://github.com/dart-lang/sdk/issues/55058