#6611·uppy

@uppy/core: destroy() does not cancel the initial online-status timeout

Author: beaussanCreated Sep 24, 2026Updated Sep 24, 2026

Initial checklist

  • I understand this is a bug report and questions should be posted in the Community Forum.
  • I searched existing issues and linked relevant results below.

Link to runnable example

Minimal reproduction

Proposed fix with regression tests

Steps to reproduce

Reproduced with @uppy/core 6.0.1, jsdom 26.1.0, and Node.js 26.5.0. The example requires no React or Vitest.

bash
git clone --branch codex/uppy-destroy-timeout \
  https://github.com/beaussan/github-repros.git uppy-destroy-timeout
cd uppy-destroy-timeout
pnpm install --frozen-lockfile
pnpm repro

The script creates an Uppy instance, immediately destroys it, then tears down the DOM:

javascript
import Uppy from '@uppy/core'
import { JSDOM } from 'jsdom'

const dom = new JSDOM('<!doctype html>')
globalThis.window = dom.window

const uppy = new Uppy()
uppy.destroy()

dom.window.close()
delete globalThis.window

Approximately three seconds later, the pending callback throws:

ReferenceError: window is not defined
    at Uppy.updateOnlineStatus (.../@uppy/core/lib/Uppy.js:1135:24)

To demonstrate the lifecycle issue without removing window, run:

bash
pnpm control

This retains the DOM and logs an is-online event emitted after destroy().

Expected behavior

destroy() cancels the pending initial online-status check. The destroyed instance should not execute that callback or emit its online-status events.

Actual behavior

The timeout remains scheduled after destruction.

In a browser environment, the callback still runs against the destroyed instance. When the DOM environment has been torn down, it throws because window is no longer available.

We originally encountered this intermittently in Vitest/jsdom with @uppy/core 5.2.0: all test assertions passed, but the delayed exception failed the task. The standalone reproduction confirms the same issue in 6.0.1. We have not established a user-visible production failure.

The initial check is scheduled without retaining its handle:

typescript
setTimeout(this.#updateOnlineStatus, 3000)

Meanwhile, destroy() removes the online/offline event listeners but does not cancel this timeout.

Proposed fix: retain the timeout handle and clear it in destroy(). The patched reproduction includes that change and tests demonstrating:

Test Unpatched 6.0.1 Patched
No exception after destruction and DOM teardown Fails Passes
No delayed online-status event after destruction Fails Passes
Live instances retain their initial check and event handling Passes Passes

Both original real-timer reproduction commands also exit successfully with the patch.

Related: #3026 addressed online/offline event-listener cleanup. This report concerns the separately scheduled timeout.