nguyenbatranvan / vite-multiple-assets

npm package
https://www.npmjs.com/package/vite-multiple-assets
8 stars 7 forks source link

[Bug] Cannot set headers after they are sent to the client #7

Closed qlaffont closed 7 months ago

qlaffont commented 8 months ago

Hi, I am using this plugin and I have a log who is emitted on vite. This issue is not fatal, I can access to my assets but i prefer to share it to fix it :

GET http://localhost:3100/fonts/Steradian/steradian-rg-webfont.woff2
An unhandled error occured: Error: Cannot set headers after they are sent to the client
    at new NodeError (node:internal/errors:405:5)
    at ServerResponse.setHeader (node:_http_outgoing:648:11)
    at handleNodeResponse (file:///home/quentin/Documents/dev/madeformed/starter-web/node_modules/.pnpm/solid-start@0.3.9_@solidjs+meta@0.29.1_@solidjs+router@0.8.3_solid-js@1.8.5_solid-start-node@0.3.9_vite@4.5.0/node_modules/solid-start/node/fetch.js:171:16)
    at startHandler (file:///home/quentin/Documents/dev/madeformed/starter-web/node_modules/.pnpm/solid-start@0.3.9_@solidjs+meta@0.29.1_@solidjs+router@0.8.3_solid-js@1.8.5_solid-start-node@0.3.9_vite@4.5.0/node_modules/solid-start/dev/server.js:140:7)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Regards

nguyenbatranvan commented 8 months ago

Hi, I am using this plugin and I have a log who is emitted on vite. This issue is not fatal, I can access to my assets but i prefer to share it to fix it :

GET http://localhost:3100/fonts/Steradian/steradian-rg-webfont.woff2
An unhandled error occured: Error: Cannot set headers after they are sent to the client
    at new NodeError (node:internal/errors:405:5)
    at ServerResponse.setHeader (node:_http_outgoing:648:11)
    at handleNodeResponse (file:///home/quentin/Documents/dev/madeformed/starter-web/node_modules/.pnpm/solid-start@0.3.9_@solidjs+meta@0.29.1_@solidjs+router@0.8.3_solid-js@1.8.5_solid-start-node@0.3.9_vite@4.5.0/node_modules/solid-start/node/fetch.js:171:16)
    at startHandler (file:///home/quentin/Documents/dev/madeformed/starter-web/node_modules/.pnpm/solid-start@0.3.9_@solidjs+meta@0.29.1_@solidjs+router@0.8.3_solid-js@1.8.5_solid-start-node@0.3.9_vite@4.5.0/node_modules/solid-start/dev/server.js:140:7)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Regards

Can you explain more clearly what the problem is?

qlaffont commented 8 months ago

The problem is when i try to access some assets : The assets is correctfully downloaded BUT an error is display on vite console " Error: Cannot set headers after they are sent to the client"

qlaffont commented 7 months ago

any update on this ?

nguyenbatranvan commented 7 months ago

any update on this ?

I'm still present. But right now I'm overloaded with personal projects. Please give me a little more time, next week at the latest, I will solve this problem for you!!

nguyenbatranvan commented 7 months ago

i don't know exactly, is the problem with SSR?

qlaffont commented 7 months ago

Yes i have ssr enabled

nguyenbatranvan commented 7 months ago

Yes i have ssr enabled

I see you are using solid-start!! Maybe I need time to use my plugin with this library to find the exact cause

nguyenbatranvan commented 7 months ago

The problem is when i try to access some assets : The assets is correctfully downloaded BUT an error is display on vite console " Error: Cannot set headers after they are sent to the client"

It would be great if you could provide a repo or code snippet where you encountered the problem!!

qlaffont commented 7 months ago

Yes no problem i will create a repro today ! I keep you in touch !

qlaffont commented 7 months ago

Here the repro : https://github.com/qlaffont/solid-start-project

I take an example with favicon.ico

nguyenbatranvan commented 7 months ago

Here the repro : https://github.com/qlaffont/solid-start-project

I take an example with favicon.ico

tks so much!!

nguyenbatranvan commented 7 months ago

Hi, I am using this plugin and I have a log who is emitted on vite. This issue is not fatal, I can access to my assets but i prefer to share it to fix it :

GET http://localhost:3100/fonts/Steradian/steradian-rg-webfont.woff2
An unhandled error occured: Error: Cannot set headers after they are sent to the client
    at new NodeError (node:internal/errors:405:5)
    at ServerResponse.setHeader (node:_http_outgoing:648:11)
    at handleNodeResponse (file:///home/quentin/Documents/dev/madeformed/starter-web/node_modules/.pnpm/solid-start@0.3.9_@solidjs+meta@0.29.1_@solidjs+router@0.8.3_solid-js@1.8.5_solid-start-node@0.3.9_vite@4.5.0/node_modules/solid-start/node/fetch.js:171:16)
    at startHandler (file:///home/quentin/Documents/dev/madeformed/starter-web/node_modules/.pnpm/solid-start@0.3.9_@solidjs+meta@0.29.1_@solidjs+router@0.8.3_solid-js@1.8.5_solid-start-node@0.3.9_vite@4.5.0/node_modules/solid-start/dev/server.js:140:7)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Regards

Hi!!! I have released version 1.2.7, you can try again!!

qlaffont commented 7 months ago

I can confirm it works ! I close the issue !

nguyenbatranvan commented 7 months ago

I can confirm it works ! I close the issue !

i released version 1.2.8. With ssr i vite.congfig.ts

DynamicPublicDirectory(["../../../shared-assets"],{
            ssr:true
        })]
qlaffont commented 7 months ago

mimeTypes is required when i specify ssr is it normal ? @nguyenbatranvan

nguyenbatranvan commented 7 months ago

mimeTypes is required when i specify ssr is it normal ? @nguyenbatranvan

what!!! mimeTypes not required!!

qlaffont commented 7 months ago

image

nguyenbatranvan commented 7 months ago

image

i seen!! What is ts version?

qlaffont commented 7 months ago

5.2.2

nguyenbatranvan commented 7 months ago

5.2.2

yess!! Maybe they should all be optional =))

nguyenbatranvan commented 7 months ago

5.2.2

yess!! Maybe they should all be optional =))

fixed v 1.2.9