diff --git a/src/classes/IntervalClient.ts b/src/classes/IntervalClient.ts index bffc45a..ccb783d 100644 --- a/src/classes/IntervalClient.ts +++ b/src/classes/IntervalClient.ts @@ -337,8 +337,13 @@ export default class IntervalClient { if (this.#isInitialized && !this.#reinitializeTimeout) { this.#reinitializeTimeout = setTimeout(async () => { - await this.#initializeHost() - this.#reinitializeTimeout = null + try { + await this.#initializeHost() + } catch (err) { + this.#logger.error('Failed to reinitialize on routes change', err) + } finally { + this.#reinitializeTimeout = null + } }, this.#reinitializeBatchTimeoutMs) } } @@ -789,7 +794,8 @@ export default class IntervalClient { this.#resendPendingPageLayouts() }) .catch(err => { - this.#logger.debug('Failed resending saved calls', err) + this.#logger.debug('Failed reestablishing connection', err) + this.#isConnected = false }) this.#log.prod( diff --git a/src/examples/basic/index.ts b/src/examples/basic/index.ts index 5e18f22..d69bc0d 100644 --- a/src/examples/basic/index.ts +++ b/src/examples/basic/index.ts @@ -260,6 +260,11 @@ const prod = new Interval({ backgroundable: true, handler: async () => { const first = await io.input.text('First input') + await ctx.loading.start({ + label: 'Thinking...', + description: 'This will take 5 seconds, feel free to navigate away.', + }) + await sleep(5_000) const second = await io.input.text('Second input') return { first, second }