File tree Expand file tree Collapse file tree 3 files changed +21
-21
lines changed
javascript/node/selenium-webdriver Expand file tree Collapse file tree 3 files changed +21
-21
lines changed Original file line number Diff line number Diff line change 8
8
via tha API, ` safari.Options#useLegacyDriver ` , to use the safari
9
9
extension driver.
10
10
* Updated the ` lib/proxy ` module to support configuring a SOCKS proxy.
11
+ * For the ` promise.ControlFlow ` , fire the "uncaughtException" event in a new
12
+ turn of the JS event loop. As a result of this change, any errors thrown by
13
+ an event listener will propagate to the global error handler. Previously,
14
+ this event was fired with in the context of a (native) promise callback,
15
+ causing errors to be silently suppressed in the promise chain.
11
16
12
17
### API Changes
13
18
Original file line number Diff line number Diff line change @@ -644,18 +644,6 @@ function asyncRun(fn) {
644
644
}
645
645
646
646
647
- /**
648
- * Throws an error asynchronously so it is reported to the global error handler.
649
- *
650
- * @param {!Error } error The error to throw.
651
- */
652
- function asyncThrow ( error ) {
653
- setTimeout ( function ( ) {
654
- throw error ;
655
- } , 0 ) ;
656
- }
657
-
658
-
659
647
/**
660
648
* @param {number } level What level of verbosity to log with.
661
649
* @param {(string|function(this: T): string) } loggable The message to log.
@@ -2297,13 +2285,14 @@ class ControlFlow extends events.EventEmitter {
2297
2285
this . cancelShutdown_ ( ) ;
2298
2286
this . cancelHold_ ( ) ;
2299
2287
2300
- var listeners = this . listeners (
2301
- ControlFlow . EventType . UNCAUGHT_EXCEPTION ) ;
2302
- if ( ! listeners . size ) {
2303
- asyncThrow ( /** @type {!Error } */ ( error ) ) ;
2304
- } else {
2305
- this . reportUncaughtException_ ( error ) ;
2306
- }
2288
+ setTimeout ( ( ) => {
2289
+ let listeners = this . listeners ( ControlFlow . EventType . UNCAUGHT_EXCEPTION ) ;
2290
+ if ( ! listeners . size ) {
2291
+ throw error ;
2292
+ } else {
2293
+ this . reportUncaughtException_ ( error ) ;
2294
+ }
2295
+ } , 0 ) ;
2307
2296
}
2308
2297
2309
2298
/**
Original file line number Diff line number Diff line change @@ -96,7 +96,10 @@ describe('promise', function() {
96
96
// so tearDown() doesn't throw
97
97
app . removeAllListeners ( ) ;
98
98
app . on ( promise . ControlFlow . EventType . UNCAUGHT_EXCEPTION , handler ) ;
99
- return NativePromise . resolve ( ) . then ( ( ) => handler . assertCalled ( ) ) ;
99
+ return NativePromise . resolve ( )
100
+ // Macro yield so the uncaught exception has a chance to trigger.
101
+ . then ( ( ) => new NativePromise ( resolve => setTimeout ( resolve , 0 ) ) )
102
+ . then ( ( ) => handler . assertCalled ( ) ) ;
100
103
} ) ;
101
104
} ) ;
102
105
@@ -312,7 +315,10 @@ describe('promise', function() {
312
315
app . removeAllListeners ( ) ;
313
316
app . on ( promise . ControlFlow . EventType . UNCAUGHT_EXCEPTION , handler ) ;
314
317
315
- return NativePromise . resolve ( ) . then ( handler . assertCalled ) ;
318
+ return NativePromise . resolve ( )
319
+ // Macro yield so the uncaught exception has a chance to trigger.
320
+ . then ( ( ) => new NativePromise ( resolve => setTimeout ( resolve , 0 ) ) )
321
+ . then ( handler . assertCalled ) ;
316
322
} ) ;
317
323
318
324
it ( 'cannotResolveADeferredWithItself' , function ( ) {
You can’t perform that action at this time.
0 commit comments