D
Deno

help

Deno stopps at file.read()

MMqx2/9/2023
I am currently working on a way to communicate with a COM device. I can successfully open and read from the COM port. The only problem is, is there is no data on the COM port Deno pauses at that point in the code because the Promise gets neither resolved or rejected. Here is the link to the Stackoverflow problem. https://stackoverflow.com/questions/75400521/abort-promise-after-delay-in-deno
Stack Overflow
Abort Promise after delay in Deno
I am currently trying to open a COM port with Deno. This works so far and I can read the data with file.read(buffer). The only problem now is that if there is no more data in the COM port and I try...
MMqx2/9/2023
Hope someone can help 👍🏻
AAapoAlas2/9/2023
setTimeout and call close on your COM instance to close the read.
MMqx2/9/2023
I tried that and it does not work…
AAapoAlas2/9/2023
You can also do a await Promise.race([file.read(), new Promise(res => setTimeout(res, TIMEOUT_MS))]) in the read method to internally include a timeout. I can't remember if the read API supports it but if it does then AbortSignal is a "native" way to cancel an ongoing promise.
MMqx2/9/2023
Yes ChatGPT also suggested that 😅 only problem is that the program does not close because there are this one pending promise The AbortSignal only works on readTextFile() method file.read(buffer) has no abortSignal
AAapoAlas2/9/2023
Hmm, does it not close even if you call the close() on it afterwards? I guess the readable stream API might offer what you need, though I don't know how much you need the "read n chars" API you have for COM right now. Note though that file.read(buffer) does not guarantee that the buffer is "filled". It returns the number of bytes actually read.
MMqx2/9/2023
A readable stream does not work because the COM ports are some how different
AAapoAlas2/9/2023
There is also some internal API at least for unref'ing a Promise, ie. telling Deno that you do not care about a given Promise resolving or not anymore...
MMqx2/9/2023
Okay
AAapoAlas2/9/2023
Possibly Deno[Deno.internal].unrefPromise
MMqx2/9/2023
I hope that they add a serial API in the future… Okay
UUUnknown User2/9/2023
Message Not Public
Sign In & Join Server To View
MMqx2/10/2023
Nope 😅 I have written with djDev (creator of deno_seial) library and he fixed some parts. But set main branch still does not work. The library he created is awesome, but you need to use a sub branch that is not listed. The branch is als unstable. https://raw.githubusercontent.com/DjDeveloperr/deno_serial/bddff5b/mod.ts I am just @ˋMqxxˋ on GitHub
AAapoAlas2/10/2023
What sort of fixes did you make?
UUUnknown User2/10/2023
Message Not Public
Sign In & Join Server To View
MMqx2/10/2023
I did no fixes

Looking for more? Join the community!

Recommended Posts
[Resolved][Fresh] How to load data asynchronously after rendering a page ?Hi ! I was wondering if someone could help me understand the paradigm to load data asynchronously afSupabase Auth UI in FreshI'm building a simple web. I'd like to use Supabase's Auth UI, namely the `Auth` component, for handAny tool that will complie my TS code to JS?I have coded a website in typescript using Deno, but I want to convert it to JS code. I know the DenHow to get remote IP address when using Deno.serve?I'm using connInfo when using Deno from STD but the native http server doesn't seem to have such intTwo questions on documentationRTFM in 3... 2... 🙂 Question 1: How do i hide documentation for specific exports, i do not want Is there any simple way to keep track of the heap/stack usage of a running Deno application?I have made a Deno application and I'm curious to know if there's heap/stack issues that I should fiusing data from one deno bench in anotheris there any good way to re-use the results generated in one deno bench in another one? example: `docker compose up of Oak server throws: SyntaxError: Duplicate export of 'type'I am just learning how to use Docker, and am trying to put up a container of an Oak server. When runPublishing Deno Module with Bin (Answered)I know there's a way to include a `bin/` when publishing a module and then perform some kind of `denUse local tgz file instead of tgz from npm registryHello, Is it possible to reference a local tgz file inside a deno project (like calling `npm instalvscode LSP being a disgraceful little bitchfor no reason obvious to me, vscode and deno's lsp has been acting up lately. any ideas what could bIs there a way to fetch() with headers, WITHOUT forcing header keys to lowercase?Title. I'm trying to create an API wrapper for a service which uses "Incapsula" as their firewall orHow do I use std/log?I'm trying to create a log file. I don't seem to be able to make it work tho. ```ts import { handleop_ffi_cstr_read replacement now that deno.core.ops is gone?The latest release removed Deno.core.ops, which a library of mine relied on to use `op_ffi_cstr_readNPM Import results in Rust panicLooking to import the Airgram NPM package because I don't want to write it from scratch at this momeDeno fmt conflicting with Deno lint, when using IIFE```ts // before formating ((): void => { /* code */ })() ``` after formating with deno fmt, it adds prototype dot functions. How?How would I go about creating dot function that can be chained at the end of a number in Deno? ExamRepublish a /x/ module from a deleted repoIs it possible to publish an old module from a new repo? i'v deleted an old one and created a new reHow to get Deno to fmt on save with VSCode?I have a deno.json file with some fmt options which works if run fromt the command line but not whenIntegrate Twin to Svelte+Vite+Deno as FreshIs there any way to integrate the use of Twind into the Stelte+Vite+Deno project as Fresh does? Tha