#TypeError argument entity must be string, Buffer, or fs.Stats

1 messages · Page 1 of 1 (latest)

ebon yacht
#

I'm getting this error trying to serve static files with express.js on bun. I think the issue is related to tsconfig.json but I haven't been able to fix it. Error: ```// validate argument
82 | if (!isStats && typeof entity !== 'string' && !Buffer.isBuffer(entity)) {
83 | throw new TypeError('argument entity must be string, Buffer, or fs.Stats')
^
TypeError: argument entity must be string, Buffer, or fs.Stats
at etag (/home/is/geegees/node_modules/etag/index.js:83:10)
at setHeader (/home/is/geegees/node_modules/send/index.js:880:14)
at send (/home/is/geegees/node_modules/send/index.js:620:2)
at onstat (/home/is/geegees/node_modules/send/index.js:725:4)

brittle gazelle
#

can you show what you're passing to send()?

#

probably fs.Stats

#

is the answer

ebon yacht
#

i'm just trying to access /scripts/loginForm.js

#

app.use(express.static('public'))

#

What is fs.stats for?

brittle gazelle
#

probably etag is using it

ebon yacht
#

any ideas for a fix? setting etag to false app.use(express.static('public', { etag: false })); just breaks it even more: TypeError: Right hand side of instanceof is not an object at isFsReadStream (/home/is/geegees/node_modules/destroy/index.js:164:9) at destroy (/home/is/geegees/node_modules/destroy/index.js:36:6) at cleanup (/home/is/geegees/node_modules/send/index.js:796:4)

brittle gazelle
#

we really need to add tests that include express

#

so that we can catch this stuff

#

but there's a way to disable etag from express more generally

#

app.set('etag', false); // turn off

#

or

#

app.disable('etag')

ebon yacht
#

etag does this

#

var Stats = require('fs').Stats

#

console.log(Stats) is undefined

#

idk what that means

#

but maybe thats something?

#

i dont think the etag code considers if its there

brittle gazelle
#

okay i see

#

the bug is that we aren't exposing Stats as a class

ebon yacht
#

is it stats particularly or

brittle gazelle
#

yeah Stats specifically

ebon yacht
#

ah i see

#

is there a quick client-side fix i could make for this? im sorry to keep bothering you lol

brittle gazelle
#

this is hacky and it might not work but

#

require("fs").Stat = require("fs").statSync(Bun.main).constructor;

#

so long as you do that before theo ther module is loaded

#

(keeping in mind that require() is executed after import)

#

can you file an issue though

#

Expose Stat class in node:fs module

ebon yacht
#

yeah for sure

#

although it seems that ReadStream doesnt exist either