raunioroo
raunioroo
DDeno
Created by Diaz Kautsar on 12/20/2024 in #help
Issue with Adding Object to S3 from Deno Deploy (Works Locally)
Hi! I'm not too familiar with deploy, or aws-sdk. But I have had success using https://deno.land/x/s3@0.5.0 as a simple, lightweight library for S3. IIRC aws-sdk was at least unnecessarily huge. Can't remember if that was the reason I ditched the official aws-sdk, or was it not working with deno for some reason. Either way, the mentioned library has served me well.
3 replies
DDeno
Created by nounderline on 12/2/2024 in #help
How to exclude code and imports from deno compile binary?
I would think having 2 entrypoints like leokuma said, would be the "right" way. Deno only bundles the files that are actually used/imported beginning from the entrypoint module. One could say it's treeshaking at the file level, not invidual export level, and if the code/dependencies is properly organized, that's all the "treeshaking" you need. If your modules import a bunch of unneeded stuff, you might want to look into how you do import dependencies in general, you might be doing something wrong (or at least suboptimally). Common mistake is to use deps.ts approach to specify dependencies. That indeed tends to cause a bunch of unneeded code being loaded/included in the graph. Better to use import maps, which won't actually load the modules unless they are actually, directly used/imported by the entrypoint or it's dependencies. In any case, Deno compile binaries will always be very large, since they contain an almost complete version of deno + your code.
11 replies
DDeno
Created by yoggyd on 9/4/2024 in #help
any reason against using the deps.ts approach?
Not sure if I understand the question, but will reply anyway :) Annoyingly, JSR import paths look very different to deno.land style plain URL imports, in that they start different and end different. This means you can't just set up a prefix like "@std" in the import map, and easily switch between JSR and something else by editing the import map only. So, you need to set up and map full aliases for each possible import to be able to switch repositories or use local filesystem copy, without touching the actual import statements in code.
7 replies
DDeno
Created by yoggyd on 9/4/2024 in #help
any reason against using the deps.ts approach?
Third downside is with deps.ts will cause all referenced libraries to be loaded and initialized whether they are used or not by the main entrypoint. If using dynamic imports that problem can be amplified. With import maps you can reference as many libraries as you like, and they will only be loaded on-demand.
7 replies
DDeno
Created by Parallax on 7/9/2024 in #help
Is there a way to use Javascript as easily as Php?
VPS servers are a nice, cheap middleground between administering your own server, and ready made cloud solutions. A bit more involved in setup than your typical php service,but not too bad. Cheapest option in AWS Lightsail is around 5 bucks a month, and works great with deno (unless your app is a memory hog, in which case you should look into the more expensive options with more RAM)
40 replies
DDeno
Created by thailephan on 5/20/2024 in #help
Are there any up-to-date library for date and time in Deno?
Date and time libraries seem to be somewhat inactive since JS standard Temporal API is just around the corner, and will have/has most features you'd ever need built in. And in fact usable in Deno with - - unstable-temporal. Meanwhile, there is simple but useful and up to date https://jsr.io/@std/datetime , and like you mention could bring stuff from npm. Temporal is pretty nice though, if you are ok with using unstable stuff
3 replies
DDeno
Created by Phatso on 5/10/2024 in #help
Websockets API with async processing (is there a better way?)
Someone correct if I'm wrong, but I think worker comms involve some internal serialization under the hood (some relative of structuredClone?). Which would be faster than JSON, but slower than not reserializing. So I'd think it's probably a little faster to just send the string to the worker and parse the JSON there. Which makes sense also in that if you are using multiple workers to distribute load, you'd want to move as much processing to the workers as possible, keeping the main process as lightweight as possible (since every request goes through that single threaded "load balancer", you want to avoid it becoming a bottleneck).
12 replies
DDeno
Created by Phatso on 5/10/2024 in #help
Websockets API with async processing (is there a better way?)
Also, not sure if it applies to websockets app like yours, but I do some heavy image processing in thread pool of sorts, and found the optimal number of processing threads to be number_of_cores - 1. I assume it's because if I saturate ALL the cores completely with image processing, the various other system threads or processes may get bogged down also then everything can become a bit unresponsive. But if I always have 1 semi-idle core, the system always has a place to execute background stuff on, resulting in smoother overall performance and even if slightly less "images per second", the performance "per image" is more consistent and predictable.
12 replies
DDeno
Created by Phatso on 5/10/2024 in #help
Websockets API with async processing (is there a better way?)
Just a thought: Could each worker have a standalone websocket server, just on their own ports? Clients would connect directly to own worker port, assigned somehow to balance workload to the number of cores. This would negate the need for all connections to go through the main process/thread, as well as negate redundant message serialization & deserialization between workers and the main process (JSON.parse and I assume passing messages to workers involve some semi-expensive IPC-like message serialization under the hood).
12 replies
DDeno
Created by bebraw on 4/28/2024 in #help
How to abstract tests to allow running different functions against the same test suite?
Nothing public sry. But basically something along the lines of
// --------------- testsuite.js
import * as sharedTest_A from "./sharedtest_A.js";

Deno.test({
name: "testFoo",
fn: async (t) => {
await t.step("sharedTest_A", async (t) => {
await sharedTest_A.testFoo(t);
await sharedTest_A.testBar(t);
});
// await t.step("sharedtest_B" async (t) => { ... });
}
})

// --------------- sharedtest_A.js
export async function testFoo(t) {
await t.step("test 1", async (t) => {
// do something
});
await t.step("test 2", async (t) => {
// do something
});
}
export async function testBar(t) {
await t.step("test 3", async (t) => {
// do something
});
await t.step("test 4", async (t) => {
// do something
});

}
// --------------- testsuite.js
import * as sharedTest_A from "./sharedtest_A.js";

Deno.test({
name: "testFoo",
fn: async (t) => {
await t.step("sharedTest_A", async (t) => {
await sharedTest_A.testFoo(t);
await sharedTest_A.testBar(t);
});
// await t.step("sharedtest_B" async (t) => { ... });
}
})

// --------------- sharedtest_A.js
export async function testFoo(t) {
await t.step("test 1", async (t) => {
// do something
});
await t.step("test 2", async (t) => {
// do something
});
}
export async function testBar(t) {
await t.step("test 3", async (t) => {
// do something
});
await t.step("test 4", async (t) => {
// do something
});

}
Passing t around is needed for proper nesting of steps in the output.'
5 replies
DDeno
Created by bebraw on 4/28/2024 in #help
How to abstract tests to allow running different functions against the same test suite?
I mean, for some reason I used to think test files are some special, limited dialect of JS. Once I realized it is just normal code which can be organized to modules, classes, functions, exports, imports like any other app, it suddenly felt like I gained testing superpowers.
5 replies
DDeno
Created by bebraw on 4/28/2024 in #help
How to abstract tests to allow running different functions against the same test suite?
I tend to wrap shared tests in a function, or functions which I then export (as functions I can run as test steps) . So the shared test file doesn't have side effects in the form of top level Deno.test() calls. Actual test suite then imports all the shared tests it wants and runs the functions. I find it good practice since this "libraries of test steps" approach has other bonuses: I can pass setup variables to the shared test step functions to simulate permutations of different environments or configs, or create fast mini test suites for things I'm currently working on, or have multiple levels of nested test steps - deno does handle and format the results of nested test steps quite nicely.
5 replies
DDeno
Created by abi on 4/14/2024 in #help
Microservices, best practices
My takeaways: 1) Minimizing the need for the services to chat with to each other is one guideline which might also naturally lead to a divide that also makes organizational sense. Chatty services blow up the whole system incredibly fast when every piece of communication adds latency in the form of serialization/deserialization step, network hop, whatever queue/messaging system step you have, each service doing their own permission checks etc. Potentially each message kicks of a chain of other messages between the interconnected network of services etc leading to exponential latencies. If you are not really, really carefull with that, you can easily end up with a system that costs like 10x-100x in server costs than what a simple monolith on a lone server could handle. 2) Don't be afraid to duplicate data. Each service owning their own data, copying and storing their own truth with some mechanism to sync up with other services, is a bit counterintuitive, but a good way to avoid said chattiness.
5 replies
DDeno
Created by abi on 4/14/2024 in #help
Microservices, best practices
5 replies
DDeno
Created by Ebiko on 4/8/2024 in #help
could not find "deno.json" after compile
No description
12 replies
DDeno
Created by Akuze on 4/8/2024 in #help
Importing Buffer Type
Yeah AI looks to be about correct about the Buffer vs Uint8Array. But I'm not crypto expert, nor TS expert, so no comments whether Uint8Array is best in this particular case, or should it be ArrayBuffer, some kind of Stream or what. Uint8Array is used a lot for simple buckets of in-memory bytes, sounds like a sensible Deno/webstandard option. IIRC Uint8Array is actually a view into a backing ArrayBuffer that contains the actual data.
5 replies
DDeno
Created by Ebiko on 4/8/2024 in #help
could not find "deno.json" after compile
https://github.com/denoland/fresh/pull/1208/files here's a relevant looking part in fresh src
12 replies
DDeno
Created by Ebiko on 4/8/2024 in #help
could not find "deno.json" after compile
I'm guessing AI is correct in that something in your code or dependencies is trying to access deno.json directly. And Fresh seems to be a likely culprit here. I don't use fresh so can't help you much further sry
12 replies
DDeno
Created by Skylark on 3/29/2024 in #help
update deno version on Alpine
you probably need to ask the alpine package maintainer, Jakub Jirutka. AFAIK deno team does not officially support/maintain any distribution packages or repositories. deno releasing every week or two, that means distro packages tend to be hopelessly outdated. if you are able, it's best to install deno using the distro-agnostic installer as per instructions on https://deno.com/ , then you can use the upgrade feature too
8 replies
DDeno
Created by raunioroo on 3/11/2024 in #help
How to troubleshoot runaway (100% CPU) deno process
For full disclosure; i'm one of the commenters in this issue, jtoppine (noticed too that someone had similar problems and had created an issue). So I guess that makes total of two people having what appears to be the same problem. I haven't run to these freezes for a while now, everything has been running smoothly since. The cause remains a mystery, and I guess low priority now that it seems like a rare occurence. I was able to implement quick detection & recovery if it ever happens again so it's not as much as a disastrous event anymore. Still interested in potential ways to investigate if these issues happen in the future though! In the github issue it was suggested to run Deno with remote debugger enabled - A good idea, but feels like not practically feasible. (running a headless cloud VPS production server with debug hook enabled, and keeping a SSH tunnel open / remote debugger connected for days in hopes the issue reproduces. That is, if the debugger and remote connection even work when the process is in a 100% CPU usage, unresponsive state) Like, maybe it could work, but I kinda gave up trying to set it up without even trying :)
9 replies