Skip to content

Instantly share code, notes, and snippets.

View bartlomieju's full-sized avatar
🦕

Bartek Iwańczuk bartlomieju

🦕
View GitHub Profile

What is a Dev Server?

A dev server is a local HTTP server optimized for the development loop. Its job is to serve your application locally with features that make iteration fast.

Core Features

  • Hot Module Replacement (HMR) — when you save a file, only the changed module is swapped in the browser without a full page reload. State (like form inputs, scroll position) is preserved.
  • On-demand transformation — instead of bundling everything upfront, modules are transformed (TypeScript → JS, JSX → JS, etc.) only when the browser requests them. This makes startup near-instant even for large projects.
  • File watching — monitors the filesystem and triggers rebuilds/HMR updates.
  • Error overlay — compilation errors are shown directly in the browser.

Issue #26142: Worker blob URL race condition — Analysis & Fix Plan

The Bug

URL.revokeObjectURL() after new Worker(blobURL) causes intermittent "Module not found" errors because blob content is fetched asynchronously on the worker thread, not during construction.

Works in Chrome/Firefox. Fails in Deno.

Race Condition

@bartlomieju
bartlomieju / worker-idle-fix-architecture.md
Created March 9, 2026 22:30
Architecture: Fix node:worker_threads idle termination (denoland/deno#23169)

Fix: node:worker_threads Worker Idle Termination (denoland/deno#23169)

Problem

Workers created with node:worker_threads are terminated when idle, even if they have ref'd transferable objects like MessagePort or SharedArrayBuffer that should keep them alive.

Root Cause: Two Competing Keepalive Systems

There are two independent keepalive decision systems, and that's the root problem:

/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./src/base.ts":
/*!*********************!*\
!*** ./src/base.ts ***!
\*********************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
addEventListener("fetch", (event) => {
new ArrayBuffer(1 << 30);
});
addEventListener("fetch", (event) => {
while (true) {}
});
addEventListener("fetch", (event) => {
throw new Error("boom!");
});
❯ cargo run -- task
Compiling deno v1.19.2 (/Users/ib/dev/deno/cli)
Finished dev [unoptimized + debuginfo] target(s) in 20.58s
Running `target/debug/deno task`
Available tasks:
- async
sleep 1 && echo 2 &
- boolean_list
echo 1 && false || echo 2
- env_var_substitution
jupyter notebook
[I 2021-12-09 17:20:32.804 LabApp] JupyterLab extension loaded from /usr/local/Cellar/jupyterlab/3.2.4/libexec/lib/python3.9/site-packages/jupyterlab
[I 2021-12-09 17:20:32.804 LabApp] JupyterLab application directory is /usr/local/Cellar/jupyterlab/3.2.4/libexec/share/jupyter/lab
[I 17:20:32.813 NotebookApp] Serving notebooks from local directory: /Users/biwanczuk/dev/ideno
[I 17:20:32.813 NotebookApp] Jupyter Notebook 6.4.6 is running at:
[I 17:20:32.813 NotebookApp] http://localhost:8888/?token=6a1b4c6d4743e5dff339982ec80ac39e758c0dd3b7e7cded
[I 17:20:32.813 NotebookApp] or http://127.0.0.1:8888/?token=6a1b4c6d4743e5dff339982ec80ac39e758c0dd3b7e7cded
[I 17:20:32.813 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 17:20:32.823 NotebookApp]
@bartlomieju
bartlomieju / inspector.js
Last active December 7, 2021 00:35
Demonstrate event loop hang if "Runtime.runIfWaitingForDebugger" is not called after connecting to Deno inspector. Forked from https://gist.github.com/evanwashere/04cfa233f613343e1c9d6fb72cfd628c
class Emitter {
#on = Object.create(null);
#once = Object.create(null);
on(n, fn) { (this.#on[n] ?? (this.#on[n] = [])).push(fn); }
once(n, fn) { (this.#once[n] ?? (this.#once[n] = [])).push(fn); }
emit(n, ...args) { this.#on[n]?.forEach(_ => _(...args)); if (this.#once[n]) this.#once[n] = (this.#once[n].forEach(_ => _(...args)), undefined); }
off(n, fn) { if (!fn) (delete this.#on[n], delete this.#once[n]); else { let o = this.#on[n]?.indexOf(fn) ?? -1; if (o !== -1) this.#on[n].splice(o, 1); o = this.#once[n]?.indexOf(fn) ?? -1; if (o !== -1) this.#once[n].splice(o, 1); } }
}