Deno

D

Deno

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

Join

Skipping time in tests; time delay setTimeout setInterval

(the title is just so people can get to this one easier by using search) I have a deadline/delay based (@std/async) functionality and in tests I want to skip time (so I don't have to pass lower values for timeouts). I want something like jest's advanceTimersByTime...

What is the best way to mock an internal import?

Hello! I'm working with Deno and I love it so far, but I've run into one issue I can't seem to figure out, regarding testing and mocking internal packages. I'd like to be able to mock imports from other files, but I'm not sure what the best way to do it is. I have a db.ts file with some Sequelize classes exported (ADatabase and BDatabase), and I use them in another class in another file (ManagerClass in manager.ts). I'd like to be able to mock the Sequelize classes ADatabase and BDatabase, or at least the upsert methods on those classes. But, the examples in the documentation for mocking don't really give examples on how to mock something without reimplementing it (they have their internal functions on a _internals object). Am I supposed to go through my ManagerClass and change how I call each method, so I can easily replace those functions with stubbed/spied versions? Or can I change the self param on stub() to globalThis? I'm really not sure which is the correct way, or if it will even work. Please help me clear up this confusion. Thank you!...

Issue with ZMQ

Code to reproduce ```ts import { Pull } from "zeromq" console.log("Hello, world!")...

Deno project source control

Should I include deno.lock in the source control? Afaik, it is generated everytime deno install is used.

Deploying Deno as a frontend app

Hey all I'm currently working on a little personal project with a React Vite frontend running on Deno and was wondering if anyone had any recommendations on a service to use for deployment/hosting? I have tried and successfully been able to use Deno Deploy for the front/backend but I found that the frontend part of app doesn't support browser routing which is a necessary requirement for my project. I wanted to try using another service like Vercel but it seems like it doesn't support the Deno runtime for non-API applications at the moment. It seems like so far it might just be easier to go back to using npm/yarn for my frontend, while only using Deno for my backend web server, but I wanted to see if anyone out there had any suggestions. Thanks!...

Sequential queue processing with Deno KV listenQueue?

I'm working on an API endpoint that needs to process lots of calls every second. I want to make this call asynchronous so that the API returns fast and I can offload the data to be processed in the background, so I thought of using Deno.kv queues(https://docs.deno.com/deploy/kv/manual/queue_overview/). The only issue is that there is a lot of async code inside the processing jobs, and when I queue up a lot of them they seem to overlap in processing, which causes issues when accessing shared resources(db connections specifically). Is there a way to make kv.listenQueue process each entry in sequence? This is effectively my queue code: ```ts const kv = await Deno.openKv(); ...

Error when deploy on AWS Lightsail: "exec /tini: exec format error"

Following the official tutorial to deploy on AWS Lightsail. I have the same files (main.ts, Dockerfile, docker-compose.yml), and it works in local. I pushed to Docker Hub then pulled, it works as well. However, when deploy it to Lightsail, it failed with error: exec /tini: exec format error ...
No description

How to specify/identify TypeScript version?

We are migrating our codebase to TypeScript 5.6, and we would like Deno to respect that version in fmt, lint and VS Code LSP. Is the TypeScript version in Deno configurable?...
No description

Cant configure Tailwind with DaisyUI using Deno inside of Docker | Error: Cannot find module daisyui

I'm literally pulling my hair right now because i can't figure out why is it not working in my case. I got tailwind to work but i can't figure out why the DaisyUI can't be found. Im using docker for local development and here is my config related to deno. deno.json...

New to Deno, why are namespaces discouraged?

I can't find much information about this online. I'm getting this lint warning when using namespaces, but they've worked no problem when I was using plain TypeScript with Node. I'd like to be able to default import one namespace and tab-complete the functions I need. I'm using the Deno extension in VSCode....
No description

Is there an existing deno in-memory file system library similar to memfs for node?

Apologies if this is the wrong place for “does x exist” questions. Happy to move it to a more appropriate channel if needed. I came across this discussion from 2019 - https://github.com/denoland/deno/issues/1836 - and I’m wondering if anyone has implemented such a library? Update: just wanted to add that I haven’t actually tried using memfs in Deno. I just assumed it wouldn’t work....

@std:testing/mock assertSpyCall - checking args for a partially matching object.

In Jest, you can do partial object matching - like this: ```expect(obj).toEqual( expect.objectContaining({ id: '111' })...

Understanding deno test Behavior with Interdependent Modules

I'm seeking clarification on how Deno's test runner (deno test) manages interdependent modules. Consider the following module dependencies: Module A depends on Module B Module B depends on Module C If I execute deno test for Module A, will the test runner automatically execute the test cases for Modules B and C, given their dependency chain?...

Concurrent fetch timing

Hey all :playful_deno: I'm trying to find a way of accurately timing a few fetch calls that are triggered concurrently. I tried something basic, but each new request will have an increased time, probably due to the internal fetch pool having some delay to send new requests: ```...

Beginner question about Deno on the web

Hi, I've been looking into Deno recently and I love everything I'm reading so far but something I'm confused about is: what does it actually mean to use Deno for a website frontend? Isn't Deno a runtime? What can it do on the browser? I tried experimenting with SvelteKit and Deno by doing deno run -A npm:sv create, deno install, deno task dev, but as I expected, all I'm still writing is normal browser code. Where does Deno come in? Keep in mind that I'm not super well versed in a lot of web technologies so this might just be a misunderstanding on my part....

Referencing environment variables from .env in deno compile or deno task commands

Is this possible? I can reference predefined env variables like PATH fine, but any env variables that are defined in .env seems out of reach by the Deno CLI.

Deno VSCode extension issues with tsconfig.json

Hi everyone! I was following Deno's nextjs Dinasour example, and I noticed that If I enable the Deno extension I get the issues shown on the image. Anyone knows how to stop this from happening? I don't have any other related TS extensions enabled.
No description

Cannot make Koffi (npm) work with its module after compile

Hello, I wanted to try reading dll with Koffi but when it's compiled, it doesn't work because it need to access its module. I tried to include them with --include like the Koffi's documentation said https://koffi.dev/packaging but I didn't manage to make it work. I don't know if the issues is from Koffi, Deno or me being a completely idiot... You can easily test it with this code ```ts...

Access project dependency through Deno API

Maybe I am solving the wrong problem here, but I want to copy a deno dependency into my esbuild bundle so that it can be accesable on the web. The specific dependency I want is svelte. The idea was to mark it as external in the esbuild build and then just copy the dependency into the dist/ folder, see my build.ts file here: ```ts...