Skip to content

Instantly share code, notes, and snippets.

View bartlomieju's full-sized avatar
🦕

Bartek Iwańczuk bartlomieju

🦕
View GitHub Profile
❯ 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
addEventListener("fetch", (event) => {
throw new Error("boom!");
});
addEventListener("fetch", (event) => {
while (true) {}
});
addEventListener("fetch", (event) => {
new ArrayBuffer(1 << 30);
});
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./src/base.ts":
/*!*********************!*\
!*** ./src/base.ts ***!
\*********************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
@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:

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

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.
@bartlomieju
bartlomieju / gist:bdc1ef45bd9bba24dc4ed082555092b6
Created March 13, 2026 13:26
Investigation: Deno issue #15176 - Resolving promises in beforeunload event
# Investigation: Deno Issue #15176 — Resolving Promises in `beforeunload` Event
## The Problem
```js
await new Promise(resolve => {
window.onbeforeunload = resolve;
});
```

Should Deno Have a Global Config File?

Bun's Global Config

Bun uses bunfig.toml (TOML format) with a two-tier system:

Local Global
File bunfig.toml (project root) $HOME/.bunfig.toml or $XDG_CONFIG_HOME/.bunfig.toml
Dot prefix No Yes