Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http/2 Pushed javascript not loading #325

Open
mattoni opened this issue Jul 24, 2017 · 5 comments
Open

http/2 Pushed javascript not loading #325

mattoni opened this issue Jul 24, 2017 · 5 comments

Comments

@mattoni
Copy link

mattoni commented Jul 24, 2017

Node v8.2.1:
uname -a: Linux a1da17d8416c 4.9.36-moby #1 SMP Fri Jul 14 17:47:34 UTC 2017 x86_64 Linux:

https://stackoverflow.com/questions/45251150/http-2-pushed-javascript-not-loading

I'm building an HTTP/2 server with PUSH enabled on the spdy lib. Everything works perfectly without push enabled, but when I enable it the server is pushing empty frames.

spdy
.createServer(options, (req, res) => {
// TODO - figure out why the javascript doesnt load on the client
if (res.push) {
console.log("Pushing...");
// push vendor bundle
const bundleStream = res.push(/js/client.js, {
status: 200,
method: "GET",
request: { accept: "/" },
response: { "content-type": "application/javascript" },
});

        bundleStream.on("error", (e: any) => console.error(e));
        bundleStream.end();
        // push main bundle
        const vendorStream = res.push(`/js/vendor.js`, {
            status: 200,
            method: "GET",
            request: { accept: "*/*" },
            response: { "content-type": "application/javascript" },
        });
        vendorStream.on("error", (e: any) => console.error(e));
        vendorStream.end();
    }
    return app(req as any, res as any);
})
.listen(port, (err: any) => {

The output of nghttp -nv https:// is here: https://pastebin.com/Wuju0HR2

One of the commenters on stack overflow suggested I open up an issue here. Any help is much appreciated, thanks!

@GuskiS
Copy link

GuskiS commented Aug 2, 2017

Having the same issue. It seems that JS files are corrupted.

@mattoni
Copy link
Author

mattoni commented Aug 23, 2017

Were you able to find a workaround?

@threehams
Copy link

Same issue with both JS and CSS.

@webcarrot
Copy link
Contributor

webcarrot commented Jan 8, 2018

Send file content:

// ...
vendorStream.on("error", (e: any) => console.error(e));
const stream = fs.createReadStream(`${somedir}/js/vendor.js`);
stream.pipe(vendorStream);
// vendorStream.end(); - fs stream end  vendorStream
// ...

or if content is Buffer/string:

// ...
vendorStream.on("error", (e: any) => console.error(e));
vendorStream.end(vendorFileBuffer)
// ...

PS. add some compression "negotiation" ( br, lzma, gzip, plain ) and serve best file prepared on build + headers...

@duterte
Copy link

duterte commented Nov 26, 2020

Looks like this repository is no longer maintained

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants