D
Deno

help

How to optimize imports on deno deploy?

Ppatrickalima981/10/2024
I have a medium project (44 files) deployed on deno deploy, where works. But, I'm getting inconsistent and sometimes very long cold start times in my deno project, like the attached image. All my dependencies:
{
"std/": "https://deno.land/std@0.205.0/",
"hono/": "https://deno.land/x/hono@v3.9.2/",
"fs/": "https://deno.land/std@/fs/",
"dotenv": "npm:dotenv",
"drizzle-orm": "npm:drizzle-orm",
"drizzle-kit": "npm:drizzle-kit",
"drizzle-orm/sqlite-core": "npm:drizzle-kit",
"@vinejs/vine": "npm:@vinejs/vine",
"@vinejs/compiler/types": "https://cdn.jsdelivr.net/npm/@vinejs/compiler@2.2.0/build/src/types.d.ts",
"uuidv4": "npm:uuidv4",
"rambda": "npm:rambda",
"hasha": "npm:hasha",
"upstash_redis": "https://deno.land/x/upstash_redis@v1.14.0/mod.ts",
"ioredis": "npm:ioredis",
"dayjs": "npm:dayjs",
"drizzle-typebox": "npm:drizzle-typebox",
"@sinclair/typebox": "npm:@sinclair/typebox",
"drizzle-orm/pg-proxy": "npm:drizzle-orm/pg-proxy",
"postgres": "https://deno.land/x/postgres@v0.17.0/mod.ts"
}
{
"std/": "https://deno.land/std@0.205.0/",
"hono/": "https://deno.land/x/hono@v3.9.2/",
"fs/": "https://deno.land/std@/fs/",
"dotenv": "npm:dotenv",
"drizzle-orm": "npm:drizzle-orm",
"drizzle-kit": "npm:drizzle-kit",
"drizzle-orm/sqlite-core": "npm:drizzle-kit",
"@vinejs/vine": "npm:@vinejs/vine",
"@vinejs/compiler/types": "https://cdn.jsdelivr.net/npm/@vinejs/compiler@2.2.0/build/src/types.d.ts",
"uuidv4": "npm:uuidv4",
"rambda": "npm:rambda",
"hasha": "npm:hasha",
"upstash_redis": "https://deno.land/x/upstash_redis@v1.14.0/mod.ts",
"ioredis": "npm:ioredis",
"dayjs": "npm:dayjs",
"drizzle-typebox": "npm:drizzle-typebox",
"@sinclair/typebox": "npm:@sinclair/typebox",
"drizzle-orm/pg-proxy": "npm:drizzle-orm/pg-proxy",
"postgres": "https://deno.land/x/postgres@v0.17.0/mod.ts"
}
After some tests, I suspect there is a problem with Imports, because only to import a module with 5x files the deploy is having 2 secs, sometimes 4 secs. I would like to know if this is normal and if not, How can i fix it?
No description
Ppatrickalima981/10/2024
This is other big cold start:
Ppatrickalima981/10/2024
No description
Rraunioroo1/10/2024
I'm not that familiar with deploy, but many npm packages tend to be huuuuuge. eg. drizzle here is 5mb of code, vine 2mb. it doesn't matter how many files your project is, if your npm deep dependencies are 100x-1000x that (i guess that's the nature of npm ecosystem) - not that surprising if cold starts are high. Libraries made specifically for deno tend to be much smaller. But again I'm not sure if there are ways to optimize that on deploy. Just my personal experience; it's best to bring from npm only what you absolutely need and can't find elsewhere.
Ppatrickalima981/10/2024
Maybe you're right. I'll try do some lazy load for my handlers based in the route to see if I can get some result. Maybe it can help
Ppatrickalima981/11/2024
Create a lazy loading system give better results. However after 24 hours, I get random and some times long long very cold start.
No description
Ppatrickalima981/11/2024
This problem its not 100% for all locations. For example the first request of the day for us-east-4 and europe in general is acceptable. The main problem is in the south america

Looking for more? Join the community!

Recommended Posts
LSP complains about missing package mongodbVS Code keeps complaining about "uncached or missing npm package: mongodb". `Cache "npm:mongodb" andnode.js to Deno remix template migrationI would like to migrate one of the templates in remix from node.js to Deno. I am not sure how to do How to pass value from one form to another?I want to design a form which has two input text field. What users type in field 1 will be passed toHow to build a Response object with the 'url' property setWriting unit tests. Some functions parse Response objects. How do I create some where the `url` propWhy Deno is not a library?For example, I'd like to embed JavaScript (Deno) on FreeBasic or Rust to able Users to write JavaScr`deno cache` consistently failing with the same errorerror: error sending request for url (https://deno.land/std@0.152.0/http/negotiation.ts): dispatch tDoes fetch() support upgrading the connection to a websocket?What happens when `fetch()` gets the response ``` HTTP/1.1 101 Switching Protocols connection: upgrError: Not implemented: crypto.Sign``` Error: Not implemented: crypto.Sign at notImplemented (https://deno.land/std@0.177.1/node/_uHow can I access req object inside a render() function from fresh plugin?Is it possible?Deno Deploy KV: Gateway TimeoutI been using KV on this project since closed beta and it worked great, but since yesterday **Write OSlow loading time on localhostAs discussed in https://discord.com/channels/684898665143206084/991511118524715139/11935856237103104How to set env variable for preview branch?I'm getting just errors that they are missingPrisma error when trying to push/migrate db```bash PS C:\Users\adubo\Desktop\freshchat> deno task push Task push deno run -A npm:prisma@latest Does the deno-astro-adapter will be updated to use astro 4? https://github.com/denoland/deno-astro-aDoes the deno-astro-adapter will be updated to use astro 4? https://github.com/denoland/deno-astro-a