File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change 3
3
var domain = require ( 'domain' ) ;
4
4
5
5
var eos = require ( 'end-of-stream' ) ;
6
- var tick = require ( 'next-tick ' ) ;
6
+ var tick = require ( 'process-nextick-args ' ) ;
7
7
var once = require ( 'once' ) ;
8
8
var exhaust = require ( 'stream-exhaust' ) ;
9
9
@@ -25,14 +25,14 @@ function asyncDone(fn, cb) {
25
25
}
26
26
27
27
function onSuccess ( result ) {
28
- return done ( null , result ) ;
28
+ tick ( done , null , result ) ;
29
29
}
30
30
31
31
function onError ( error ) {
32
32
if ( ! error ) {
33
33
error = new Error ( 'Promise rejected without Error' ) ;
34
34
}
35
- return done ( error ) ;
35
+ tick ( done , error ) ;
36
36
}
37
37
38
38
function asyncRunner ( ) {
@@ -43,7 +43,7 @@ function asyncDone(fn, cb) {
43
43
}
44
44
45
45
function onCompleted ( ) {
46
- return onSuccess ( onNext . state ) ;
46
+ onSuccess ( onNext . state ) ;
47
47
}
48
48
49
49
if ( result && typeof result . on === 'function' ) {
Original file line number Diff line number Diff line change 27
27
},
28
28
"dependencies" : {
29
29
"end-of-stream" : " ^1.1.0" ,
30
- "next-tick" : " ^1.0.0" ,
31
30
"once" : " ^1.3.2" ,
31
+ "process-nextick-args" : " ^1.0.7" ,
32
32
"stream-exhaust" : " ^1.0.1"
33
33
},
34
34
"devDependencies" : {
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
+ var domain = require ( 'domain' ) ;
4
+
3
5
var expect = require ( 'expect' ) ;
4
6
5
7
var when = require ( 'when' ) ;
@@ -41,4 +43,17 @@ describe('promises', function() {
41
43
done ( ) ;
42
44
} ) ;
43
45
} ) ;
46
+
47
+ it ( 'does not swallow thrown errors in callback' , function ( done ) {
48
+ var d = domain . create ( ) ;
49
+ d . once ( 'error' , function ( err ) {
50
+ expect ( err ) . toExist ( ) ;
51
+ done ( ) ;
52
+ } ) ;
53
+ d . run ( function ( ) {
54
+ asyncDone ( success , function ( ) {
55
+ throw new Error ( 'Boom' ) ;
56
+ } ) ;
57
+ } ) ;
58
+ } ) ;
44
59
} ) ;
You can’t perform that action at this time.
0 commit comments