After a brief hiatus while npm fixed their WAF...
tRPC v11.22 is out, now with typesafe procedure errors! Using this API, @trpc/openapi will also emit accurate error responses
@brophdawg11@npmjs@Cloudflare Thanks for the tip, good to know it could be a readme. Looks like a different cause for us though, between the last successful publish and the first failure, readmes didn't change, not much changed even in code π£
How did you guys figure it out? Any contacts/support involved?
Since September, we have been unable to publish because every URL under `PUT https://t.co/LCQI7jouwM` is being blocked by a @npmjs@Cloudflare WAF. You can even prove it locally, they've just wholesale blocked our npm scope.
Support have not yet done anything to help.
tRPC canβt publish new package versions for at least a week now, and it looks like an @npmjs Cloudflare WAF is blocking our @github actions from publishing on a vanilla GitHub runner
Anyone out there who can help?
How is @trpcio `httpBatchLink` able to fold multiple procedure calls into ONE batched call?
Like how does `Promise.all([a.query(), b.query()])` end up in only a single HTTP request
It's a pure timing trick built with a simple dataloader:
Every call you make in the same tick gets pushed into one shared buffer. Only the very first call schedules a `setTimeout(dispatch)`
Because `setTimeout` is a macrotask, it only runs after your synchronous code finishes. So by the time `dispatch` fires, all the calls from that tick are sitting in the buffer together
`dispatch` then joins them into one request (`a,b,c`), sends it, and resolves each call's individual promise from the response array
The neat part: `Promise.all` isn't special. Anything called in the same tick batches. The only thing that breaks it is an `await` in between, which yields to the event loop and flushes early
I think this is a really elegant design: using the language's semantics for batching instead of exposing an explicit API
On the side I'm setting up fumadocs (by @fuma_nama) by piping @colinhacks's @trpcio routers through `trpc/openapi` (alpha) to get well designed auto-generating docs.
Some rough edges but working well so far.
tRPC OpenAPI support isn't just about generating clients. You can use @oasdiff on your own API to check for breaking changes or generate changelogs too