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

Crash when loading page before bundle ready #46

Open
phiresky opened this issue Jun 11, 2017 · 1 comment
Open

Crash when loading page before bundle ready #46

phiresky opened this issue Jun 11, 2017 · 1 comment

Comments

@phiresky
Copy link

phiresky commented Jun 11, 2017

The browser gets a Not Found response, the server crashes with

Error: Can't set headers after they are sent.
    at validateHeader (_http_outgoing.js:504:11)
    at ServerResponse.setHeader (_http_outgoing.js:511:3)
    at Object.set (./node_modules/koa/lib/response.js:440:16)
    at Object.proto.(anonymous function) [as set] (./node_modules/delegates/index.js:40:31)
    at Object.setHeader (./node_modules/koa-webpack-middleware/lib/devMiddleware.js:29:23)
    at Object.handleRangeHeaders (./node_modules/webpack-dev-middleware/lib/Shared.js:61:8)
    at processRequest (./node_modules/webpack-dev-middleware/middleware.js:63:21)
    at continueBecauseBundleAvailable (./node_modules/webpack-dev-middleware/lib/Shared.js:122:6)
    at Array.forEach (native)
    at ./node_modules/webpack-dev-middleware/lib/Shared.js:121:9
    at _combinedTickCallback (internal/process/next_tick.js:95:7)
    at process._tickDomainCallback (internal/process/next_tick.js:198:9)

Even though webpack says webpack: wait until bundle finished: /

I've included the middleware as follows:

app.use(devMiddleware(webpack([config]), {
    watchOptions: {
        aggregateTimeout: 300,
        poll: true
    },
    historyApiFallback: true
}));

I'm using

koa-webpack-middleware@^1.0.5:
  version "1.0.5"
@akatebi
Copy link

akatebi commented Jul 8, 2017

I switched to the "webpack-koa2-middleware" package for the "devMiddleware". The usage is exactly the same, it's a simple drop in. This fixed my issue. I noticed that the new package does not respond to requests until Webpack has finished building. I suggest that this package should do the same to avoid this issue. Thanks!

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

No branches or pull requests

2 participants