Version : v10.6.0
Platform : Linux 4.15.0-24-generic GitHub issue management #26 ~16.04.1-Ubuntu SMP Fri Jun 15 14:35:08 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Subsystem :
The code bellow will end with output:
and then it ends. The expected output is:
and the node should not exit
function sleep ( ms ) {
return new Promise ( ( resolve ) => { setTimeout ( resolve , ms ) } )
}
class TestClass {
async processData ( data ) {
return new Promise ( ( resolver , rejecter ) => {
console . log ( 'working' )
} )
}
}
class RunnerClass {
async start ( ) {
const instance = new TestClass ( )
while ( true ) {
console . log ( 'Looping' )
if ( true ) {
try {
console . log ( 'before' )
const processedData = await instance . processData ( 'data' )
console . log ( 'after' )
} catch ( error ) {
console . log ( 'errored' )
}
}
await sleep ( 1000 )
}
}
}
async function run ( ) {
const rebalancer = new RunnerClass ( )
await rebalancer . start ( )
console . log ( 'end' )
}
run ( )
If the if statment is set to if (false) then the process is outputting:
Looping
Looping
Looping
...
and never ends...