Deno

D

Deno

Chat about Deno, a modern runtime for JavaScript and TypeScript.

Join

not sure why this code is erroring

```typescript for (const number of genNumbers()) { const result = await fetchPages(number); if (result instanceof Error) break; const urls = parse(result);...

Why doesn't POST response from serveTls support streaming chunks from a ReadableStream?

We can POST a ReadableStream to a serveTls server, however when we respond with a ReadableStream the chunks don't actually get sent to the client until we call controller.close() on the client. The means we have to make a POST request first, then a GET request to write to an upload stream and read the response stream from the server at the same time. Some code https://www.reddit.com/r/Deno/comments/150wet7/comment/js69iu6/?context=3.

When I use npm: node: specifiers how can I specify the version?

We know in Deno we can do import { Client, Pool } from "https://deno.land/x/pg@v0.6.1/mod.ts"; I want to use npm:axios but how can I specify the version of axios like 1.1.2...

FakeTime seems to break async tests

I am attempting to use FakeTime similarly to in the Faking time example of https://deno.land/manual@v1.35.1/basics/testing/mocking But whenever I run the tests it responds with:
error: Promise resolution is still pending but the event loop has already resolved"...

How to serve HTTPS with the Deno.serve() API

I used to start a dev server with TLS like so ```const server = Deno.listenTls({ port: 7000, transport: 'tcp',...

Custom console.log formatting for a class/object

Is there a way to change the way an object/class is printed in the console? For example, instead of ``` [1, 2, 3, 4]...

Is there a way to write to a file by replacing bytes?

Like "I am a looong file" > write('Test') > 'Test a looong file'

std/http/server: URI too long —how to avoid loading those?

Using https://deno.land/std@0.194.0/http/server.ts, is there a way to reject long URIs before they are loaded in memory? I have a middleware that responds with 414 URI Too Long when the URI length is > 8192, but this only saves me from the cost of parsing that thing —it's still already loaded in memory even if it's 1MB in size. How can I get the server to close the connection when the URI grows beyond 8k instead?...

Worker: TS2304 [ERROR]: Cannot find name 'postMessage'

When type-checking a worker script that uses the global postMessage() method, deno check gives a TS2304 [ERROR]: Cannot find name 'postMessage' error. Is there any workaround?

How to recover from worker death? It terminates my main program…

In the error message handler, I replace the dead worker with a new one, but it kills my program either way. Full repro & log at https://gist.github.com/jcayzac/48ae8304a6b3c790353c52f98e242904 Thanks!...

Is there anyone using kv with pentagon ORM and Zod ?

I've tried using pentagon for Deno kv in a Fresh project, and it seems like it's not working.

Prefix Kv keys with a base part

Currently I add base() to all keys:
kv.set([base(), "foo"], value)
kv.set([base(), "foo"], value)
...

Caching old versions

Why is deno caching old versions even tho the version is specified

deno check: Module '"internal:///missing_dependency.d.ts"' has no exported member...

The sequence of events: - Upgraded to Deno 1.35.0 - ran deno check on my code - got an error like the one described in https://github.com/denoland/deno/issues/11196 (AssertionError: data unexpectedly null) - tried the suggestion from that issue, namely replaced path with types in my triple slash reference comments...

cargo compile size 160M

When using cargo install deno the result is 160M, if there's info on shrinking this somewhere please let me know. (Or if this question belongs in another channel.) Thanks very much. Side Note: I'm doing this on a Raspberry Pi which works fine and I'm also not aware of other working option(s) for the latest version. The snap option wouldn't install correctly on some of these raspberry pi's and the deno from the pi4 works on all the pi3's I have which are running the Raspberry Pi OS with Debian 11 (64bit all)....

Deno type enforcement

Hey, I have a question about the type checking. ```ts function logging(message : number) { console.log(message); }...

Avoiding use-after-free

I encountered a use-after-free issue when writing an FFI binding. The code looks like this. ```ts const lib = Deno.dlopen("libexample.dylib", { /** * Fills newly allocated memory with data sampled from an external source....

DNS Records and Deno

so I am confused I'm building an application that uses Steam's web API and am looking at why the response times are taking so long and with the perf headers I have in my application I can see it takes a while to make the requests (260-300 ms) so I investigated where Steam's API servers are located and found that there is one in Los Angeles so I spun up an EC2 instance there and pinged the domain name api.steampowered.com and the latency was still ~260 ms...

Fresh pattern help

Could anyone possibly help guide me to understand the 'freshest' pattern for the following, please? When a user hits / I load a login page, and once he submits the form, the server generates some session data in the POST handler for /, and then redirects(send back a 303) to /chat. There is an island on /chat which needs to contain the session data. How would I redirect from the form POST handler, to the /chat page and make sure that my state is passed to the island? In react or similar I would handle the 'form submission' in javascript and cache the returned session data before redirecting to /chat. Since fresh seems to promote the use of native forms I'm trying to learn how I would handle this situation. I'm thinking of setting a cookie in the redirect, to then be sent with the /chat GET, which I can use to return the page with session data inside. Is that common? Thanks!...

Deno seems to assume wrong return type (Puppeteer)

With the following code, I get an type error which I do not expect: ```ts const element: ElementHandle | null = await page.$('span.label-status'); const shouldBeString: string = await element?.$eval('a', (el): string => el.innerText);...