I got error on webpack-div-middleware
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 257
- Forks
- 27
- PR merge metrics
- No merged PRs in 30d
Description
TypeError: Cannot read property 'filename' of undefined
at /Users/nico/node/react-koa2-server/node_modules/koa-react-view/index.js:152:36
at Array.forEach (native)
at cleanCache (/Users/nico/node/react-koa2-server/node_modules/koa-react-view/index.js:151:30)
at Object.app.context.render (/Users/nico/node/react-koa2-server/node_modules/koa-react-view/index.js:85:9)
at home.js:32:21
at /Users/nico/node/react-koa2-server/node_modules/react-router/lib/match.js:65:5
at /Users/nico/node/react-koa2-server/node_modules/react-router/lib/createTransitionManager.js:118:11
at done (/Users/nico/node/react-koa2-server/node_modules/react-router/lib/AsyncUtils.js:79:19)
at /Users/nico/node/react-koa2-server/node_modules/react-router/lib/AsyncUtils.js:85:7
at getComponentsForRoute (/Users/nico/node/react-koa2-server/node_modules/react-router/lib/getComponents.js:15:5)
at /Users/nico/node/react-koa2-server/node_modules/react-router/lib/getComponents.js:41:5
at /Users/nico/node/react-koa2-server/node_modules/react-router/lib/AsyncUtils.js:84:5
at Array.forEach (native)
at mapAsync (/Users/nico/node/react-koa2-server/node_modules/react-router/lib/AsyncUtils.js:83:9)
at getComponents (/Users/nico/node/react-koa2-server/node_modules/react-router/lib/getComponents.js:40:28)
at finishEnterHooks (/Users/nico/node/react-koa2-server/node_modules/react-router/lib/createTransitionManager.js:112:35)
And I found the error in the code
function cleanCache(match) {
Object.keys(require.cache).forEach(function(module) {
if (match(require.cache[module].filename)) {
delete require.cache[module];
}
});
}
It should be
function cleanCache(match) {
Object.keys(require.cache).forEach(function(module) {
if (require.cache[module] && require.cache[module].filename && match(require.cache[module].filename)) {
delete require.cache[module];
}
});
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the cleanCache function in the koa-react-view source and inspect how entries in require.cache are handled during rendering. Reproduce the reported error through the render path in the issue, then verify that entries without a filename no longer cause the failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100