mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Merge branch 'dev' into rfdc
This commit is contained in:
		| @@ -1718,9 +1718,13 @@ describe('function node', function() { | ||||
|     describe("init function", function() { | ||||
|  | ||||
|         it('should delay handling messages until init completes', function(done) { | ||||
|             const timeoutMS = 200; | ||||
|             // Since helper.load uses process.nextTick timers might occasionally finish | ||||
|             // a couple of milliseconds too early, so give some leeway to the check. | ||||
|             const timeoutCheckMargin = 5; | ||||
|             var flow = [{id:"n1",type:"function",wires:[["n2"]],initialize: ` | ||||
|                 return new Promise((resolve,reject) => { | ||||
|                     setTimeout(resolve,200) | ||||
|                     setTimeout(resolve, ${timeoutMS}); | ||||
|                 })`, | ||||
|                 func:"return msg;" | ||||
|             }, | ||||
| @@ -1733,9 +1737,10 @@ describe('function node', function() { | ||||
|                     msg.delta = Date.now() - msg.payload; | ||||
|                     receivedMsgs.push(msg) | ||||
|                     if (receivedMsgs.length === 5) { | ||||
|                         var errors = receivedMsgs.filter(msg => msg.delta < 200) | ||||
|                         let deltas = receivedMsgs.map(msg => msg.delta); | ||||
|                         var errors = deltas.filter(delta => delta < (timeoutMS - timeoutCheckMargin)) | ||||
|                         if (errors.length > 0) { | ||||
|                             done(new Error(`Message received before init completed - was ${msg.delta} expected >300`)) | ||||
|                             done(new Error(`Message received before init completed - delta values ${JSON.stringify(deltas)} expected to be > ${timeoutMS - timeoutCheckMargin}`)) | ||||
|                         } else { | ||||
|                             done(); | ||||
|                         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user