frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Show HN: Knowledge-Bank

https://github.com/gabrywu-public/knowledge-bank
1•gabrywu•4m ago•0 comments

Show HN: The Codeverse Hub Linux

https://github.com/TheCodeVerseHub/CodeVerseLinuxDistro
3•sinisterMage•5m ago•0 comments

Take a trip to Japan's Dododo Land, the most irritating place on Earth

https://soranews24.com/2026/02/07/take-a-trip-to-japans-dododo-land-the-most-irritating-place-on-...
2•zdw•5m ago•0 comments

British drivers over 70 to face eye tests every three years

https://www.bbc.com/news/articles/c205nxy0p31o
4•bookofjoe•6m ago•1 comments

BookTalk: A Reading Companion That Captures Your Voice

https://github.com/bramses/BookTalk
1•_bramses•6m ago•0 comments

Is AI "good" yet? – tracking HN's sentiment on AI coding

https://www.is-ai-good-yet.com/#home
1•ilyaizen•7m ago•1 comments

Show HN: Amdb – Tree-sitter based memory for AI agents (Rust)

https://github.com/BETAER-08/amdb
1•try_betaer•8m ago•0 comments

OpenClaw Partners with VirusTotal for Skill Security

https://openclaw.ai/blog/virustotal-partnership
2•anhxuan•8m ago•0 comments

Show HN: Seedance 2.0 Release

https://seedancy2.com/
2•funnycoding•9m ago•0 comments

Leisure Suit Larry's Al Lowe on model trains, funny deaths and Disney

https://spillhistorie.no/2026/02/06/interview-with-sierra-veteran-al-lowe/
1•thelok•9m ago•0 comments

Towards Self-Driving Codebases

https://cursor.com/blog/self-driving-codebases
1•edwinarbus•9m ago•0 comments

VCF West: Whirlwind Software Restoration – Guy Fedorkow [video]

https://www.youtube.com/watch?v=YLoXodz1N9A
1•stmw•10m ago•1 comments

Show HN: COGext – A minimalist, open-source system monitor for Chrome (<550KB)

https://github.com/tchoa91/cog-ext
1•tchoa91•11m ago•1 comments

FOSDEM 26 – My Hallway Track Takeaways

https://sluongng.substack.com/p/fosdem-26-my-hallway-track-takeaways
1•birdculture•11m ago•0 comments

Show HN: Env-shelf – Open-source desktop app to manage .env files

https://env-shelf.vercel.app/
1•ivanglpz•15m ago•0 comments

Show HN: Almostnode – Run Node.js, Next.js, and Express in the Browser

https://almostnode.dev/
1•PetrBrzyBrzek•15m ago•0 comments

Dell support (and hardware) is so bad, I almost sued them

https://blog.joshattic.us/posts/2026-02-07-dell-support-lawsuit
1•radeeyate•16m ago•0 comments

Project Pterodactyl: Incremental Architecture

https://www.jonmsterling.com/01K7/
1•matt_d•16m ago•0 comments

Styling: Search-Text and Other Highlight-Y Pseudo-Elements

https://css-tricks.com/how-to-style-the-new-search-text-and-other-highlight-pseudo-elements/
1•blenderob•18m ago•0 comments

Crypto firm accidentally sends $40B in Bitcoin to users

https://finance.yahoo.com/news/crypto-firm-accidentally-sends-40-055054321.html
1•CommonGuy•19m ago•0 comments

Magnetic fields can change carbon diffusion in steel

https://www.sciencedaily.com/releases/2026/01/260125083427.htm
1•fanf2•19m ago•0 comments

Fantasy football that celebrates great games

https://www.silvestar.codes/articles/ultigamemate/
1•blenderob•19m ago•0 comments

Show HN: Animalese

https://animalese.barcoloudly.com/
1•noreplica•20m ago•0 comments

StrongDM's AI team build serious software without even looking at the code

https://simonwillison.net/2026/Feb/7/software-factory/
3•simonw•20m ago•0 comments

John Haugeland on the failure of micro-worlds

https://blog.plover.com/tech/gpt/micro-worlds.html
1•blenderob•21m ago•0 comments

Show HN: Velocity - Free/Cheaper Linear Clone but with MCP for agents

https://velocity.quest
2•kevinelliott•21m ago•2 comments

Corning Invented a New Fiber-Optic Cable for AI and Landed a $6B Meta Deal [video]

https://www.youtube.com/watch?v=Y3KLbc5DlRs
1•ksec•23m ago•0 comments

Show HN: XAPIs.dev – Twitter API Alternative at 90% Lower Cost

https://xapis.dev
2•nmfccodes•23m ago•1 comments

Near-Instantly Aborting the Worst Pain Imaginable with Psychedelics

https://psychotechnology.substack.com/p/near-instantly-aborting-the-worst
2•eatitraw•29m ago•0 comments

Show HN: Nginx-defender – realtime abuse blocking for Nginx

https://github.com/Anipaleja/nginx-defender
2•anipaleja•30m ago•0 comments
Open in hackernews

A job queue in two lines of JavaScript

https://jameshfisher.com/2025/07/07/a-job-queue-in-two-lines-of-js/
57•chmaynard•7mo ago

Comments

lerp-io•6mo ago
The chain variable continuously grows because each call to enqueue() creates a new promise that references the previous one. This creates an ever-growing chain of promises that never gets garbage collected.
ath92•6mo ago
Couldn’t the browser garbage collect the promises (and their callbacks) that have been rejected or resolved? I.e. effectively “shift” the promises at the start of the queue that have been dealt with and will never be relevant again?

At least this stackoverflow answer suggests the handlers are GC’ed: https://stackoverflow.com/questions/79448475/are-promise-han...

jameshart•6mo ago
Why does the promise returned by a promise’s then() method need to reference that promise?

The original promise needs to reference the chained promise, not the other way round.

As jobs complete I would expect the top of the chain to be eligible to be garbage collected.

paulddraper•6mo ago
Though it seems like that, no.

  a = b.then(c);
When `b` is resolved, it is garbage collected, even if a reference to `a` is retained.

(If the runtime maintains async stack traces, that could be an issue...but that is a common issue, and the stack depth is limited.)

bapak•6mo ago
That's not how promises work, there's no chain. It's no different from

    await job1()
    await job2()
    await job3()
    await job4()
Except dynamic
ameliaquining•6mo ago
At least in V8, this is not the case. To prove it, start a Chromium-based browser with the command-line flag --js-flags=--expose-gc, then go to https://runjs.app/play/#aWYgKCF3aW5kb3cuZ2MpIHsKICB0aHJvdyBu...
bigiain•6mo ago
> This creates an ever-growing chain of promises that never gets garbage collected.

Modern frontend development performance best practise is to allow for garbage collection only when the browser crashes.

moralestapia•6mo ago
Nope.
Inviz•6mo ago
I wonder if people who are claiming its not the case ever tried to use promises in hardcore ways like this, chaining 10s of thousands of calls. You often hit some bullshit, i.e. Promise.race is a big cause of issues.

Even if you are doing `then().then()`, something _else_ in the code base could retain the promise somehow and then your whole chain isn't GCable!

For example https://github.com/rxaviers/async-pool library that implements concurrency for async iterators (and uses promise.race) subtly creates GC pressure which you dont see until you make a whole lot of calls and suddenly its slow

gabrielsroka•6mo ago
That's TS, not JS.
90s_dev•6mo ago
For now.

https://github.com/tc39/proposal-type-annotations

jameshart•6mo ago
One line of TS, then two lines of JS (with a type annotation in one of them)
goloroden•6mo ago
It’s not even 2 lines:

1. Type definition 2. Chain definition 3. Enqueue definition

jakelazaroff•6mo ago
Line 1 is fully erased when transpiling, leaving two lines of JavaScript.
Brian_K_White•6mo ago
But you still had to write it and it's required to get the result, so I don't see any rational for not counting it.

Transpilation does not change the fact that the input is these 3 lines of code in 2 different languages.

jakelazaroff•6mo ago
Right, and only two of those lines are JavaScript. The type definition is not required to get the result.
metadat•6mo ago
I noticed the same thing when I saw the code. Is it honest for TFA to title it as "2-lines of Javascript" in this case?
dcre•6mo ago
Oh, come on.
egorfine•6mo ago
I came here to make the same comment.

I wonder why are you downvoted for being as factual and neutral as it is technically possible.

ameliaquining•6mo ago
I think because a reader who doesn't want to use TypeScript can trivially remove the type annotations, so they're not actually a barrier to using this code in JavaScript. Some people might also be suspicious that the reason to bring this up is to imply hostility to JavaScript tooling that requires a build step, since it's become popular to hate on this.
egorfine•6mo ago
So as a community of developers we're totally okay calling TypeScript "JavaScript" because ... mentioning that hard cold fact is a sign of hostility towards TS? Ok. Got it.
90s_dev•6mo ago
I came across this trick a few months ago when I was dealing with what seemed to be a race condition from a chrome-only API, and I just felt so clever! I don't remember though whether the race condition actually was one or not though, and I eventually had to rip that entire class out of my codebase. But it's such a good feeling to know I came up with a solution that clever all by myself.
Inviz•6mo ago
Chaining promises like this is not a good idea for high throughput cases (creates gc pressure), but perfectly valid for regular cases.
paulddraper•6mo ago
Huh?

It creates 1 object allocation per enqueue.

Inviz•6mo ago
yeah but it creates closure as well, which typically references some objects that isn't easy to GC. So if you have long-living promise with some data captured in closure, it will not be cleared. So doing then().then().then() may not release objects referenced in callbacks that resolved time ago.
paulddraper•6mo ago
There are zero closures here.
vivzkestrel•6mo ago
A production grade application would need a much more robust mechanism like BullMQ
ameliaquining•6mo ago
There are use cases for a non-persistent task queue, like doing things one at a time on the frontend. (JavaScript is single-threaded but will interleave multiple separate async call chains that each span multiple event-loop iterations, and there could be situations where you might not want that.)
theThree•6mo ago
Something like this?

async function runTasks(tasks: Job[]) { for (let task of tasks) { try { await task() } catch (e) { } } }

foxygen•6mo ago
This only works if you have the full list of tasks beforehand.
neals•6mo ago
Anybody willing to walk me through this code? I don't get it.
foxygen•6mo ago
chain is a global variable. It starts with an empty promise. First call to enqueue changes the (global)value of chain to emptyPromise.then(firstJob), second call to enqueue changes it to emptyPromise.then(firstJob).then(secondJob) and so on.
fwlr•6mo ago
JavaScript promises are objects with a resolver function and an internal asynchronous computation. At some point in the future, the asynchronous computation will complete, and at that point the promise will call its resolver function with the return value of the computation.

`prom.then(fn)` creates a new promise. The new promise’s resolver function is the `fn` inside `then(fn)`, and the new promise’s asynchronous computation is the original promise’s resolver function.

cluckindan•6mo ago
If you wanted to e.g. log something on failures, you’d need to do something like this:

    chain
      .then(job)
      .catch((err) => {
        console.error(err);
        return job();
      });
Otherwise failures would need to be logged by the job itself before rejecting the promise.
egorfine•6mo ago
> If you need a job queue in JS

  type Job = () => Promise<unknown>;
This is not JS.
ameliaquining•6mo ago
It's trivial to remove the type annotations.
ameliaquining•6mo ago
To make it slightly more idiomatic, you can use chain.finally(job) instead of chain.then(job, job). (All browsers have supported this API for over seven years.)