spdy-http2 / node-spdy

SPDY server on Node.js
2.81k stars 196 forks source link

FF works but Chrome gives - push is not a function - v3.4.* #292

Closed eddyparkinson closed 7 years ago

eddyparkinson commented 7 years ago

FireFox works but Chrome (Version 54.0.2840.71 m (64-bit)) gives - push is not a function - error also fails with MS Edge

Looks like issue #275 but I tried spdy@3.4.0 spdy@3.4.2 & spdy@3.4.4 - got the same error.

error is on line: var stream = res.push('/main.js', {

This code:

const http2 = require('spdy')
const logger = require('morgan')
const express = require('express')
const app = express()
const fs = require('fs')

app.use(logger('dev'))

app.get('/', function (req, res) {
  res.send(`hello, http2!
go to /pushy`)
})

app.get('/pushy', (req, res) => {
  var stream = res.push('/main.js', {
    status: 200, // optional
    method: 'GET', // optional
    request: {
      accept: '*/*'
    },
    response: {
      'content-type': 'application/javascript'
    }
  })
  stream.on('error', function() {
  })
  stream.end('alert("hello from push stream!");')
  res.end('<script src="/main.js"></script>')
})

var options = {
  key: fs.readFileSync('./server.key'),
  cert: fs.readFileSync('./server.crt')
}

http2
  .createServer(options, app)
  .listen(8080, ()=>{
    console.log(`Server is listening on https://localhost:8080.
You can open the URL in the browser.`)
  }
)
azat-co commented 7 years ago

@eddyparkinson weird, when I developed it—all worked :)

eddyparkinson commented 7 years ago

Chrome error - fixed by upgading node

I was getting: TypeError: res.push is not a function…. Think I had node v.4.x

upgraded to - node 6.9.1 - and all worked.
Worked on Chrome & MS Edge & FF.