wulfey
wulfey
DDeno
Created by wulfey on 11/9/2023 in #help
Connect to a WebSocket through a HTTP(S)/SOCKS5 proxy
Title - I am trying to connect to a wss:// websocket through a proxy of choice at runtime. Is there a way to do this alike to Deno.createHttpClient for regular requests? If not (and I would say it is in fact more complicated), what should I do to achieve this?
2 replies
DDeno
Created by wulfey on 8/1/2023 in #help
Proper usage of `Deno.HttpClient`
Hi! I'm creating an application which allows the internal use of HTTP proxies for certain tasks. In that case, fetch() requests are given an instance of Deno.HttpClient per proxy, but for multiple fetch() calls, if they're supposed to use the same proxy, the same HttpClient instance is used. This is something I am curious about, should I create a new HttpClient for every executed fetch(), or is it fine to reuse the same HttpClients for multiple requests?
2 replies
DDeno
Created by wulfey on 4/22/2023 in #help
Preventing `Deno.stdin` reads from blocking
In a module for reading Deno.stdin input, there is a loop that reads and parses the returned bytes. My issue is that, in case of an uncaught error/rejection, the process hangs until stdin has something to return, and once it does, only then does it exit the process and log the error information. Is there a way to make this read() non-blocking in that sense? If the user does not input anything, but an error occurs, the process should exit immediately and not have to wait for a keypress. The code below can be run from a file for demonstration.
// Uncaught error timeout
setTimeout(() => { throw new Error(); }, 5000);

const input = Deno.stdin;
input.setRaw(true, Deno.build.os === "windows" ? undefined : { cbreak: true });
while (true) {
let bytes: Uint8Array = new Uint8Array(4096);
// If an uncaught error occurs somewhere else
// Deno waits for the read to complete before exiting.
await input.read(bytes);
console.log("read some bytes");
/* ... */
}
// Uncaught error timeout
setTimeout(() => { throw new Error(); }, 5000);

const input = Deno.stdin;
input.setRaw(true, Deno.build.os === "windows" ? undefined : { cbreak: true });
while (true) {
let bytes: Uint8Array = new Uint8Array(4096);
// If an uncaught error occurs somewhere else
// Deno waits for the read to complete before exiting.
await input.read(bytes);
console.log("read some bytes");
/* ... */
}
12 replies
DDeno
Created by wulfey on 2/12/2023 in #help
Properly continuously read data from a Reader
What's the proper way to continuously read from a Deno.Reader? I'm trying to parse incoming HTTP2 frames from a Deno.TlsConn, but my current method of reading involves two sets of while loops, one to continuously perform the read operation, and the other, to try read everything currently available to read from the stream in chunks of 16k. Naturally, the while loops make it take approximately one entire core of my processor, which is far from ideal. Can this in any way be improved? Is there a way to know (wait for a promise to resolve or such) when there is available data?
40 replies
DDeno
Created by wulfey on 1/30/2023 in #help
Is 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 or something like that. Issue is, when making a fetch() request through Deno, the request gets blocked, with the exact same required header and parameter structure as done through say a web browser (simple GET) or an API testing app. I noticed that the flushed HTTP headers are forced lowercase (which is good, in most cases), which I feel like is causing issues with this very specific API (specifically, only my Deno requests are blocked). Any way to flush headers as-is? (Or is a custom request/fetch library required for this)
16 replies
DDeno
Created by wulfey on 10/24/2022 in #help
Resolving 'dynamically imported module evaluation pending, but no pending ops'
I've been getting this error quite a lot, but I haven't found a single way to know which unresolved promises cause it.
error: Dynamically imported module evaluation is still pending but there are no pending ops. This situation is often caused by unresolved promises.
Pending dynamic modules:
- file:///home/user/Desktop/js/denolasvegas/commands/main/CATEGORY.ts
error: Dynamically imported module evaluation is still pending but there are no pending ops. This situation is often caused by unresolved promises.
Pending dynamic modules:
- file:///home/user/Desktop/js/denolasvegas/commands/main/CATEGORY.ts
Any tips on what to do to find the cause of these cases?
65 replies