Skip to content

Commit 12cd725

Browse files
committed
fix: don't perform any work after completing future
I got an "undefined" error in the catch branch. The only way this should be possible if registering a listener fails.
1 parent bb5d60d commit 12cd725

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

wakelock_plus/lib/assets/no_sleep.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,15 @@ var NoSleep = (function () {
129129
.then(function (wakeLock) {
130130
_this2._wakeLock = wakeLock
131131
_this2.nativeEnabled = true
132-
_nativeEnabledCompleter.complete()
133-
_nativeEnabledCompleter = null
132+
134133
// We now have a wakelock. Notify all of the existing callers.
135134
_this2._wakeLock.addEventListener('release', function () {
136135
_this2.nativeEnabled = false
137136
_this2._wakeLock = null
138137
})
138+
139+
_nativeEnabledCompleter.complete()
140+
_nativeEnabledCompleter = null
139141
})
140142
.catch(function (err) {
141143
_this2.nativeEnabled = false

0 commit comments

Comments
 (0)