Web: TypeError: null is not an object (evaluating '_nativeEnabledCompleter.completeError') on overlapping enable() calls
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- dart, javascript
調査の方向性
lib/assets/no_sleep.js の enable() と _playVideoCompleter の処理から始める。各呼び出しがローカル参照ではなくモジュールレベルの _nativeEnabledCompleter を読み取るため、null に設定され処理済みの completer が次の .then/.catch をクラッシュさせる。issue が提案するローカル参照パターンを両方の completer に適用し、その後 (Safari/web で) WakelockPlus.enable() を待機せずに繰り返し呼び出して検証し、リポジトリのテストスイート (dart test / flutter test) と Web ビルドを実行して、未処理の rejection が残っていないことを確認する。
索引モデルが issue の本文から書いたものです。
説明
Version: 1.7.0. The same code is still in main.
Platform: Web, Safari / iOS PWA
Description
In lib/assets/no_sleep.js, all calls to enable() share the module-level _nativeEnabledCompleter. Overlapping enable() calls can end up using the same completer while each sends its own navigator.wakeLock.request('screen'). The first request to settle completes the completer and sets it to null. When the next request settles, its handler calls _nativeEnabledCompleter.completeError(...) on null; on success it calls .complete() instead.
The TypeError is thrown inside a .catch handler of a promise that nothing awaits. Dart code can't catch it, so it surfaces as an unhandled rejection. Our Sentry has about 19K events of it, mostly from Safari, where wakeLock.request often rejects with NotAllowedError.
Steps to reproduce
Call WakelockPlus.enable() several times without awaiting, for example on every route change, in Safari.
Suggested fix
In each enable() call, keep a local reference to the completer and use that reference in .then / .catch, instead of reading the shared variable:
var completer = _nativeEnabledCompleter
navigator.wakeLock.request('screen')
.then(function (wakeLock) { /* ... / completer.complete(); if (_nativeEnabledCompleter === completer) _nativeEnabledCompleter = null })
.catch(function (err) { / ... */ completer.completeError(errorMessage); if (_nativeEnabledCompleter === completer) _nativeEnabledCompleter = null })
return completer.future
_playVideoCompleter is handled the same way and has the same problem.
Workaround
On our side, we now run enable() / disable() one at a time and skip a call when the wakelock is already in the requested state.
- 主要言語
- Dart
- スター
- 110
- フォーク
- 99
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
fluttercommunity/wakelock_plus のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
fluttercommunity/wakelock_plus#117 · コメント 2 件 · リアクション 2 件 ·
-
window不能编译オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 55/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
fluttercommunity/wakelock_plus の issue をすべて見る
似ている issue
-
[CarouselView] Crash (RangeError / ArgumentError) when children or itemCount is empty with infinite: true or CarouselController.animateToItem対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンp: material_ui package platform-android platform-ios platform-linux platform-macos platform-web team-design
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
flutter/flutter#195878 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[genkit_google_genai] Gemini tool call with no arguments fails with "requires a non-null input"対応中かも @kenzieschmoll が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
genkit-ai/genkit-dart#692 ·
メンテナーはふだん 11 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
lollipopkit/flutter_server_box#1851 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信