frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

You can't cancel a JavaScript promise (except sometimes you can)

https://www.inngest.com/blog/hanging-promises-for-control-flow
30•goodoldneon•2h ago

Comments

dimitropoulos•1h ago
> Libraries like Effect have increased the popularity of generators, but it's still an unusual syntax for the vast majority of JavaScript developers.

I'm getting so tired of hearing this. I loved the article and it's interesting stuff, but how many more decades until people accept generators as a primitive??

used to hear the same thing about trailing commas, destructuring, classes (instead of iife), and so many more. yet. generators still haven't crossed over the magic barrier for some reason.

yeittrue•1h ago
Generators peaked in redux- saga and thunk days before we had widespread support for async/await.

You're right, mostly pointless syntax (along with Promise) now that we can await an async function anyway, especially now with for .. of to work with Array methods like .map

But there are still some use cases for it, like with Promise. Like for example, making custom iterators/procedures or a custom delay function (sync) where you want to block execution.

horsawlarway•52m ago
There just aren't that many spots where the average js dev actually needs to touch a generator.

I don't really see generators ever crossing into mainstream usage in the same way as the other features you've compared them to. Most times... you just don't need them. The other language tools solve the problem in a more widely accessible manner.

In the (very limited & niche) subset of spots you do actually need a generator, they're nice to have, but it's mostly a "library author" tool, and even in that scope it's usage just isn't warranted all that often.

game_the0ry•1h ago
Off topic, but that site has really nice design
williamdclt•52m ago
Mh, I couldn't read due to the huge contrast and had to switch to reader mode, so...
jazzypants•49m ago
I personally find it to be perfectly readable. I've heard of people with issues with white text on a black background, but I don't fully understand it. Do you have astigmatism?
game_the0ry•30m ago
I mean, I'm not a designer but it was interesting enough to call out.
pjc50•1h ago
I like how C# handles this. You're not forced to support cancellation, but it's strongly encouraged. The APIs all take a CancellationToken, which is driven by a CancellationTokenSource from the ultimate caller. This can then either be manually checked, or when you call a library API it will notice and throw an OperationCancelledException.

Edit: note that there is a "wrong" way to do this as well. The Java thread library provides a stop() function. But since that's exogenous, it doesn't necessarily get cleaned up properly. We had to have an effort to purge it from our codebase after discovering that stopping a thread while GRPC was in progress broke all future GRPC calls from all threads, presumably due to some shared data structure being left inconsistent. "Cooperative" (as opposed to preemptive) cancel is much cleaner.

CharlieDigital•55m ago
C# has very good support for this.

You can even link cancellation tokens together and have different cancellation "roots".

esprehn•47m ago
AbortSignal is same thing on the Web. It's unfortunate TC39 failed to ever bring a CancelToken to the language to standardize the pattern outside browsers.
runarberg•34m ago
TC39 seems to be failing at many things for the past 10 years.
teraflop•22m ago
I am surprised that you had to go out of your way to remove Thread.stop from existing Java code. It's been deprecated since 1998, and the javadoc page explains pretty clearly why it's inherently unsafe.

It's hard to miss all the warnings unless you're literally just looking at the method name and nothing else.

pjc50•19m ago
I was certainly surprised to see it when I found it.
cush•1h ago
GC can be very slow. Relying on it for control flow is a bold move
eithed•56m ago
> Promise itself has no first-class protocol for cancellation, but you may be able to directly cancel the underlying asynchronous operation, typically using AbortController.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

mohsen1•35m ago
Back in 2012 I was working on a Windows 8 app. Promises were really only useful on the Windows ecosystem since browser support was close to non existent. I googled "how to cancel a promise" and the first results were Christian blogs about how you can't cancel a promise to god etc. Things haven't changes so much since, still impossible to cancel a promise (I know AbortSignal exists!)
abraxas•13m ago
and so the thirty year old hackathon continues...
afarah1•11m ago
You can also race it with another promise, which e.g. resolves on timeout.
TZubiri•7m ago
If I know the javascript ecosystem, this is an opportunity for some undergrad from Kazakhstan to create a library called 'Pinky' that offers unbreakable promises, which will have 1M downloads and stars, and will allow the dev to get a US Visa and employment. The library will get additional maintainers until it balloons into 100Kloc with features like reading config files, until one day a maintainer clicks on an enlarge penis link and gets supply chained and everyone uninstalls it.

Show HN: Developed a solution to automate ASO keyword research

https://respectaso.com/
1•sinthes•9s ago•0 comments

DispoRx: Using Agentic AI as a high-fidelity simulator for ER workflows

https://www.disporx.com/resources/disporx-launches-agentic-ed
1•chmoder•17s ago•1 comments

.env is safe but your –/.claude is not

https://github.com/PrismorSec/immunity-agent/blob/main/README.md
2•noobcoder•1m ago•1 comments

Slople – Can you tell real ML papers from AI-generated ones?

https://ml5885.github.io/slople/
1•bearseascape•2m ago•1 comments

Show HN: Kindling – reverse-engineered kindlegen, ~7,000x faster in Rust

https://github.com/ciscoriordan/kindling
1•ciscoriordan•2m ago•0 comments

"whole civilization will die tonight"

https://www.cnn.com/2026/04/07/world/live-news/iran-war-trump-us-israel
1•eth0up•2m ago•1 comments

How to Think About Dynamic Systems: Working with Phase Space

https://chillphysicsenjoyer.substack.com/p/how-to-think-about-dynamic-systems
1•crescit_eundo•3m ago•0 comments

Don't get used to Skills, they'll (mostly) be gone in a year

https://armanckeser.com/writing/skills-in-a-year
1•armanckeser•4m ago•0 comments

Show HN: Video Commander – A desktop IDE for video engineers (FFmpeg, VMAF)

https://video-commander.com
1•alfg•5m ago•0 comments

Design by Hand, Code by Agent

https://cssstudio.ai
1•anyg•8m ago•1 comments

So where are all the AI apps?

https://www.answer.ai/posts/2026-03-12-so-where-are-all-the-ai-apps.html?lid=xo0tsixagpje
2•speckx•8m ago•0 comments

Show HN: Falcon Builder – the modular OS for designing and deploying AI agents

https://www.falconbuilder.dev/
1•mecarc•9m ago•0 comments

Sybilproof reputation mechanisms (2005) [pdf]

https://dl.acm.org/doi/pdf/10.1145/1080192.1080202
1•perfmode•9m ago•0 comments

How to Use Standard HTML Video and Audio Lazy-Loading

https://engineering.squarespace.com/blog/2026/how-to-use-standard-html-video-and-audio-lazy-loadi...
1•beeandapenguin•9m ago•0 comments

AI alignment: the signal is the goal

https://substack.com/home/post/p-193080562
1•atzeus•10m ago•0 comments

Show HN: Vibe-coded your repo? Drift finds the architecture problems

https://mick-gsk.github.io/drift/
1•sauremilk•11m ago•0 comments

Someone good at CSS help, my website design is dying

https://ahti.space/~nortti/writeups/my-website-design-is-dying.html
1•birdculture•11m ago•0 comments

ErrataBench – A Proofreading Benchmark for LLMs

https://revise.io/errata-bench
1•artursapek•11m ago•0 comments

OpenAI's Sam Altman tells companies to try four-day working week

https://www.thetimes.com/us/news-today/article/openai-chief-backs-four-day-week-to-spread-ai-bene...
2•romanhn•13m ago•1 comments

GitHub Copilot CLI now supports BYOK and local models

https://github.blog/changelog/2026-04-07-copilot-cli-now-supports-byok-and-local-models/
1•abraham•14m ago•0 comments

Ignore soft skills at your peril

https://togetherlondon.com/insights/ignore-soft-skills-at-your-peril
1•lucidplot•14m ago•0 comments

Towards a Bitter Lesson of Optimization

https://sifal.social/posts/Towards-a-Bitter-Lesson-of-Optimization-When-Neural-Networks-Write-The...
1•MostHumble•14m ago•0 comments

Metaculus: Labor Automation Tournament with $35k Prize Pool

https://www.metaculus.com/tournament/labor-hub/
1•postreal•15m ago•0 comments

I built a software for my PPL agency – now I want to sell the software as well

2•CalvinGomes•18m ago•0 comments

From Blindness to Cybersecurity: My Journey as a Blind Security Researcher

https://juanmathewsrebellosantos.com
2•azurejoga•19m ago•0 comments

How Much Compute Does China Have?

https://www.chinatalk.media/p/how-many-chips-does-china-have
2•speckx•19m ago•0 comments

I don't want an autonomous AI agent. I want a collaborator

3•robenglander•19m ago•0 comments

If you don't write it, I don't read it

https://josem.co/if-you-dont-write-it-i-dont-read-it/
3•josem•22m ago•0 comments

How Accurate Are Google's A.I. Overviews?

https://www.nytimes.com/2026/04/07/technology/google-ai-overviews-accuracy.html
2•cyndunlop•23m ago•0 comments

We Spent €11/Month Testing Docker Swarm So You Don't Have To

https://raus.cloud/blog/docker-swarm-test-11-euro-lesson/
2•eduardosanzb•24m ago•0 comments