File tree Expand file tree Collapse file tree 2 files changed +30
-8
lines changed
test/integration/promise-wrappers Expand file tree Collapse file tree 2 files changed +30
-8
lines changed Original file line number Diff line number Diff line change 1
- /*
1
+ const code = `
2
2
var config = require('../../common.js').config;
3
3
4
4
var assert = require('assert');
@@ -23,23 +23,25 @@ function test() {
23
23
24
24
let e1, e2;
25
25
26
- // TODO: investigate why connaction is still open after ENETUNREACH
26
+ // TODO: investigate why connection is still open after ENETUNREACH
27
27
async function test1() {
28
28
e1 = new Error();
29
29
const conn = await createConnection({ host: '0.42.42.42' });
30
30
let [rows, fields] = conn.query('select 1 + 1');
31
31
await Promise.all([conn.query('select 1+1'), conn.query('syntax error')]);
32
32
}
33
33
34
+ /*
34
35
test1().catch(err => {
35
36
const stack = ErrorStackParser.parse(err);
36
37
const stackExpected = ErrorStackParser.parse(e1);
37
38
assert(stack[1].getLineNumber() === stackExpected[0].getLineNumber() + 1);
38
39
});
40
+ */
39
41
40
42
async function test2() {
41
43
const conn = await createConnection(config);
42
- let [rows, fields] = conn.query('select 1 + 1');
44
+ let [rows, fields] = await conn.query('select 1 + 1');
43
45
try {
44
46
e2 = new Error();
45
47
await Promise.all([conn.query('select 1+1'), conn.query('syntax error')]);
@@ -55,4 +57,27 @@ function test() {
55
57
}
56
58
57
59
test();
58
- */
60
+
61
+ ` ;
62
+
63
+ process . on ( 'unhandledRejection' , function ( err ) {
64
+ console . log ( err . stack ) ;
65
+ } ) ;
66
+
67
+ const vm = require ( 'vm' ) ;
68
+
69
+ try {
70
+ vm . runInNewContext (
71
+ code ,
72
+ {
73
+ require : require
74
+ } ,
75
+ {
76
+ fileName : __filename ,
77
+ lineOffset : 1
78
+ }
79
+ ) ;
80
+ } catch ( err ) {
81
+ // ignore sync errors (must be syntax - async/await not supported)
82
+ console . log ( err ) ;
83
+ }
Original file line number Diff line number Diff line change @@ -51,9 +51,6 @@ function testErrors() {
51
51
var connResolved ;
52
52
var connPromise = createConnection ( config ) ;
53
53
54
- console . log ( '=== 1' , connPromise ) ;
55
- console . log ( '=== 2' , connPromise . end ) ;
56
-
57
54
connPromise
58
55
. then ( function ( conn ) {
59
56
connResolved = conn ;
@@ -154,7 +151,7 @@ function testEventsConnect() {
154
151
doneEventsConnect = events === 5 ;
155
152
} ) ;
156
153
157
- conn . connection . emit ( 'error' ) ;
154
+ conn . connection . emit ( 'error' , new Error ( ) ) ;
158
155
conn . connection . emit ( 'drain' ) ;
159
156
conn . connection . emit ( 'connect' ) ;
160
157
conn . connection . emit ( 'enqueue' ) ;
You can’t perform that action at this time.
0 commit comments