@@ -210,11 +210,23 @@ const { registerInlineComplete } = require('../inlineComplete');
210210
211211// ── the network: the only stand-in ───────────────────────────────────────────────────────────────
212212const tick = ( ) => new Promise ( ( resolve ) => setImmediate ( resolve ) ) ;
213+ /** How long anything here is given to happen. Reached only by what never does. */
214+ const PATIENCE_MS = 2000 ;
215+ /**
216+ * Wait for `cond` — by the CLOCK, not by counting turns of the event loop. Inline completion waits
217+ * out its debounce on a real timer, a millisecond even when the setting is 0, and how many turns fit
218+ * into a millisecond is the machine's business: a few dozen on a Mac, well over a thousand on
219+ * Linux, where the release gate runs. A count that was plenty on one ran out on the other before
220+ * the timer had fired.
221+ */
213222async function until ( cond , what ) {
214- for ( let i = 0 ; i < 400 ; i ++ ) { if ( cond ( ) ) { return ; } await tick ( ) ; }
215- assert . fail ( 'never happened: ' + what ) ;
223+ const deadline = Date . now ( ) + PATIENCE_MS ;
224+ while ( ! cond ( ) ) {
225+ if ( Date . now ( ) > deadline ) { assert . fail ( 'never happened: ' + what ) ; }
226+ await tick ( ) ;
227+ }
216228}
217- /** Let everything already in motion get as far as it can. */
229+ /** Let everything already in motion get as far as it can. Turns, not time — so only for what no timer stands in the way of. */
218230async function settle ( ) { for ( let i = 0 ; i < 40 ; i ++ ) { await tick ( ) ; } }
219231function deferred ( ) { let resolve ; const promise = new Promise ( ( r ) => { resolve = r ; } ) ; return { promise, resolve } ; }
220232function within ( promise , ms , what ) {
0 commit comments