Cyan
Cyan
DDeno
Created by Cyan on 12/19/2024 in #help
How to set reuseaddr in `Deno.serve`?
How to set sockopt reuseaddr and reuseport with Deno.serve
6 replies
DDeno
Created by Cyan on 12/11/2024 in #help
Error sending request too quick to npm
I'm trying to make create a mirror for about 2000 packages in npm. For each package, it fetches https://registry.npmjs.org/<package> and the downloads (https://api.npmjs.org/downloads/point/last-month/<package>) with Promise.all() But there is a few errors while fetching.
Error: connection error received: not a result of an error
at mainFetch (ext:deno_fetch/26_fetch.js:182:43)
at eventLoopTick (ext:core/01_core.js:164:35)
at async fetch (ext:deno_fetch/26_fetch.js:392:7)
Error: connection error received: not a result of an error
at mainFetch (ext:deno_fetch/26_fetch.js:182:43)
at eventLoopTick (ext:core/01_core.js:164:35)
at async fetch (ext:deno_fetch/26_fetch.js:392:7)
TypeError: error sending request from ***.***.***.***:38254 for https://api.npmjs.org/downloads/point/last-month/koishi-plugin-qsign (104.16.0.35:443): client error (SendRequest): http2 error: connection error received: not a result of an error
at mainFetch (ext:deno_fetch/26_fetch.js:182:11)
at eventLoopTick (ext:core/01_core.js:164:35)
at async fetch (ext:deno_fetch/26_fetch.js:392:7)
TypeError: error sending request from ***.***.***.***:38254 for https://api.npmjs.org/downloads/point/last-month/koishi-plugin-qsign (104.16.0.35:443): client error (SendRequest): http2 error: connection error received: not a result of an error
at mainFetch (ext:deno_fetch/26_fetch.js:182:11)
at eventLoopTick (ext:core/01_core.js:164:35)
at async fetch (ext:deno_fetch/26_fetch.js:392:7)
5 replies
DDeno
Created by Cyan on 12/3/2024 in #help
process.cpuUsage() is not implemented
No description
8 replies
DDeno
Created by Cyan on 12/2/2024 in #help
koa-router behaves different in Deno
Trying to run following script
import Koa from 'koa/lib/application';
import KoaRouter from '@koa/router';

const app = new Koa({});
const router = new KoaRouter();

app.use(router.routes())
router.get("/", (ctx, next) => {
ctx.type = "text/javascript"
ctx.body = "console.log('hello')"
})

app.listen(2000)
import Koa from 'koa/lib/application';
import KoaRouter from '@koa/router';

const app = new Koa({});
const router = new KoaRouter();

app.use(router.routes())
router.get("/", (ctx, next) => {
ctx.type = "text/javascript"
ctx.body = "console.log('hello')"
})

app.listen(2000)
With Node.js, request http://127.0.0.1:2000/ gives me console.log('hello') with Content-Type set to text/javascript. But with Deno, request the same url, gives console.log('hello'), but the Content-Type is set to text/plain. Then, your browser will refuse to execute the script if the Content-Type is not correct. And everything is broken. I can't simply switch to Oakserver, this is just a minimal repro. In fact, the actual project is so large and coupled with Koa deeply. Also ctx.type works correctly without koa-router. I don't know what is going on underlying koa-router
4 replies