drift icon indicating copy to clipboard operation
drift copied to clipboard

Exception after switching from 2.15.0 to 2.20.2

Open saibotma opened this issue 1 year ago • 3 comments

A customer reported, that his app was not working any more, after he switched to the newest version of the app which switched from Drift 2.15.0 to 2.20.2. He is running macOS 10.13 and Firefox 115.0. He also seems to have similar issues when running this app on Safari on his Mac, however I currently have no stack trace.

I tried to reproduce the issue by installing Firefox 115.0 on macOS 14.6.1 without success, unfortunately.

Just posting the stack trace here, in case someone has the same problem or maybe a solution to it.

minified:awR: [Exception... "Failure"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: https://web.appella.app/drift_worker.js :: hw/$async$hw< :: line 4543"  data: no]
  at _asIntS(org-dartlang-sdk:///dart-sdk/lib/_internal/js_shared/lib/rti.dart:1598:3)
  at A.TextEditingDeltaState.inferDeltaState(drift_worker.js:665:3)
  at dartProgram(drift_worker.js:985:58)
  at dartProgram(drift_worker.js:985:58)
  at Object.hash.iv.prototypebg(org-dartlang-sdk:///dart-sdk/lib/core/uri.dart:910:31)
  at _BigIntImpl.parse.mt.prototype_BigIntImpl.parse(org-dartlang-sdk:///dart-sdk/lib/_internal/js_runtime/lib/bigint_patch.dart:155:18)
  at A.dv(org-dartlang-sdk:///lib/_engine/engine/vector_math.dart:902:16)
  at dartProgram(drift_worker.js:543:3)
  at dartProgram(drift_worker.js:985:58)
  at A.TextEditingDeltaState.inferDeltaState(org-dartlang-sdk:///lib/_engine/engine/text_editing/text_editing.dart:619:7)
  at A.h2.prototypeda(drift_worker.js:8:7)
  at A.TextEditingDeltaState.inferDeltaState(drift_worker.js:665:3)
  at dartProgram(drift_worker.js:985:58)
  at dartProgram(drift_worker.js:985:58)
  at Object.hash.iv.prototypebg(org-dartlang-sdk:///dart-sdk/lib/core/uri.dart:910:31)
  at _BigIntImpl.parse.mt.prototype_BigIntImpl.parse(org-dartlang-sdk:///dart-sdk/lib/_internal/js_runtime/lib/bigint_patch.dart:155:18)
  at A.dv(org-dartlang-sdk:///lib/_engine/engine/vector_math.dart:902:16)
  at dartProgram(drift_worker.js:543:3)
  at dartProgram(drift_worker.js:543:3)
  at A.w9(org-dartlang-sdk:///lib/_engine/engine/util.dart:430:3)
  at A.isMacOrIOS(org-dartlang-sdk:///lib/_engine/engine/util.dart:441:3)
  at dartProgram(drift_worker.js:985:58)
  at ? (<asynchronous suspension>)
  at StackTrace.current(org-dartlang-sdk:///dart-sdk/lib/_internal/js_runtime/lib/core_patch.dart:788:58)
  at DriftCommunication.request(../../../.pub-cache/hosted/pub.dev/drift-2.20.2/lib/src/remote/communication.dart:113:66)
  at A.awO.prototypeGB(../../../.pub-cache/hosted/pub.dev/drift-2.20.2/lib/src/remote/communication.dart:109:13)
  at _RemoteQueryExecutor.ensureOpen(../../../.pub-cache/hosted/pub.dev/drift-2.20.2/lib/src/remote/client_impl.dart:172:37)
  at _wrapJsFunctionForAsync(org-dartlang-sdk:///dart-sdk/lib/_internal/js_runtime/lib/async_patch.dart:303:19)
  at _wrapJsFunctionForAsync.<anonymous function>(org-dartlang-sdk:///dart-sdk/lib/_internal/js_runtime/lib/async_patch.dart:328:23)
  at _asyncStartSync(org-dartlang-sdk:///dart-sdk/lib/_internal/js_runtime/lib/async_patch.dart:233:3)
  at _RemoteQueryExecutor.ensureOpen.akT.prototypebh3(../../../.pub-cache/hosted/pub.dev/drift-2.20.2/lib/src/remote/client_impl.dart:166:12)
  at _RemoteQueryExecutor.ensureOpen.akT.prototypemM(../../../.pub-cache/hosted/pub.dev/drift-2.20.2/lib/src/remote/client_impl.dart:166:12)
  at LazyDatabase.ensureOpen.<anonymous function>(../../../.pub-cache/hosted/pub.dev/drift-2.20.2/lib/src/utils/lazy_database.dart:64:39)
  at A.cfU(org-dartlang-sdk:///dart-sdk/lib/async/zone.dart:1407:46)
  at _CustomZone.runUnary(org-dartlang-sdk:///dart-sdk/lib/async/zone.dart:1405:3)
  at _CustomZone.runUnary(org-dartlang-sdk:///dart-sdk/lib/async/zone.dart:1307:34)
  at _Future._propagateToListeners.handleValueCallback(org-dartlang-sdk:///dart-sdk/lib/async/future_impl.dart:128:29)
  at _Future._propagateToListeners(org-dartlang-sdk:///dart-sdk/lib/async/future_impl.dart:890:13)
  at _Future._completeWithValue(org-dartlang-sdk:///dart-sdk/lib/async/future_impl.dart:666:5)
  at _Future._asyncCompleteWithValue.<anonymous function>(org-dartlang-sdk:///dart-sdk/lib/async/future_impl.dart:736:7)
  at A.cfS(org-dartlang-sdk:///dart-sdk/lib/async/zone.dart:1399:12)
  at _CustomZone.run(org-dartlang-sdk:///dart-sdk/lib/async/zone.dart:1390:3)
  at _CustomZone.run(org-dartlang-sdk:///dart-sdk/lib/async/zone.dart:1300:34)
  at _CustomZone.runGuarded(org-dartlang-sdk:///dart-sdk/lib/async/zone.dart:1209:7)
  at _CustomZone.bindCallbackGuarded.<anonymous function>.bWb.prototype$0(org-dartlang-sdk:///dart-sdk/lib/async/zone.dart:1249:18)
  at _microtaskLoop(org-dartlang-sdk:///dart-sdk/lib/async/schedule_microtask.dart:40:12)
  at _startMicrotaskLoop(org-dartlang-sdk:///dart-sdk/lib/async/schedule_microtask.dart:49:5)
  at _AsyncRun._initializeScheduleImmediate.internalCallback(org-dartlang-sdk:///dart-sdk/lib/_internal/js_runtime/lib/async_patch.dart:48:10)

saibotma avatar Oct 29 '24 11:10 saibotma

Is it possible that you've upgraded drift without upgrading the drift worker? Generally that's something explicitly supported and tested, but IIRC we had a few bugs sending bigints over worker channels in older versions. These have been fixed, but required minor changes to the protocol when big ints are involved (I didn't consider this to be a breaking change because bigints were broken before).

It's possible that this can only be reproduced when a database operation actually returns a large value that can't be represented by JavaScript's number type, since IIRC we otherwise prefer to use normal numbers for efficiency.

simolus3 avatar Oct 29 '24 23:10 simolus3

The release is using the Drift worker of the 2.20.1 release: https://github.com/simolus3/drift/releases/tag/drift-2.20.1 Just double-checked, by overwriting it and then checking VCS.

saibotma avatar Oct 31 '24 11:10 saibotma

Do you have access to the raw trace as reported by Firefox? There's no inferDeltaState in the worker, so I think another tool might have applied a wrong source map here. The demangled trace when ignoring all entries that don't have drift_worker.js appears to be:

org-dartlang-sdk:///lib/_internal/js_runtime/lib/string_helper.dart 164:8  dartProgram
org-dartlang-sdk:///lib/_internal/js_shared/lib/rti.dart 1225:1            dartProgram
org-dartlang-sdk:///lib/_internal/js_shared/lib/rti.dart 1225:1            dartProgram
org-dartlang-sdk:///lib/_internal/js_shared/lib/rti.dart 1225:1            dartProgram
org-dartlang-sdk:///lib/_internal/js_runtime/lib/string_helper.dart 164:8  dartProgram
org-dartlang-sdk:///lib/_internal/js_shared/lib/rti.dart 1225:1            dartProgram
org-dartlang-sdk:///lib/_internal/js_shared/lib/rti.dart 1225:1            dartProgram
org-dartlang-sdk:///lib/_internal/js_shared/lib/rti.dart 1225:1            dartProgram

That's not really helpful...

simolus3 avatar Oct 31 '24 23:10 simolus3