@@ -5,9 +5,7 @@ const Fastify = require('../fastify')
5
5
const fp = require ( 'fastify-plugin' )
6
6
const split = require ( 'split2' )
7
7
const helper = require ( './helper' )
8
-
9
- // fix citgm @aix 72-ppc64
10
- const LISTEN_READYNESS = process . env . CITGM ? 250 : 50
8
+ const { kState } = require ( '../lib/symbols' )
11
9
12
10
let localhost
13
11
before ( async function ( ) {
@@ -1056,36 +1054,35 @@ test('async onListen does not need to be awaited', t => {
1056
1054
1057
1055
test ( 'onListen hooks do not block /1' , t => {
1058
1056
t . plan ( 2 )
1057
+
1059
1058
const fastify = Fastify ( )
1060
1059
t . teardown ( fastify . close . bind ( fastify ) )
1061
1060
1062
1061
fastify . addHook ( 'onListen' , function ( done ) {
1063
- setTimeout ( done , 500 )
1062
+ t . equal ( fastify [ kState ] . listening , true )
1063
+ done ( )
1064
1064
} )
1065
1065
1066
- const startDate = new Date ( )
1067
1066
fastify . listen ( {
1068
1067
host : 'localhost' ,
1069
1068
port : 0
1070
1069
} , err => {
1071
1070
t . error ( err )
1072
- t . ok ( new Date ( ) - startDate < LISTEN_READYNESS )
1073
1071
} )
1074
1072
} )
1075
1073
1076
1074
test ( 'onListen hooks do not block /2' , async t => {
1077
1075
t . plan ( 1 )
1076
+
1078
1077
const fastify = Fastify ( )
1079
1078
t . teardown ( fastify . close . bind ( fastify ) )
1080
1079
1081
1080
fastify . addHook ( 'onListen' , async function ( ) {
1082
- await new Promise ( resolve => setTimeout ( resolve , 500 ) )
1081
+ t . equal ( fastify [ kState ] . listening , true )
1083
1082
} )
1084
1083
1085
- const startDate = new Date ( )
1086
1084
await fastify . listen ( {
1087
1085
host : 'localhost' ,
1088
1086
port : 0
1089
1087
} )
1090
- t . ok ( new Date ( ) - startDate < LISTEN_READYNESS )
1091
1088
} )
0 commit comments