-
Notifications
You must be signed in to change notification settings - Fork 176
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
Current version(8.0.7) make Out Of Memory #54
Comments
The for loops The As for the heap memory issue, I wonder why the tests and manual checking didn't catch it. The only thing I think could be possibly causing some strange side effect is the function I made @niftylettuce any ideas? |
Our test suites are failing with "JavaScript heap out of memory" after upgrading to 8.0.7 as well, just like egaoneko is experiencing. Practically the same stacktrace as above. Only difference is that I'm using node 13.8.0. |
@JacobMGEvans |
@Gusten Would it be possible to see the tests that are failing from your code and unit it is testing? Also what is the tech stack, @egaoneko mentioned that Next.js, TS and Webpack are being used in the project that this issue is occurring? EDIT: Also, I am attempting to replicate the issue here https://codesandbox.io/s/koa-template-hv82k |
@JacobMGEvans Router.prototype.use = function () {
...
for (var i = 0; i < middleware.length; i++) {
var m = middleware[i];
if (m.router) {
var cloneRouter = Object.assign(Object.create(Router.prototype), m.router, {
stack: m.router.stack.slice(0)
});
for (var i = 0; i < cloneRouter.stack.length; i++) {
var nestedLayer = cloneRouter.stack[i];
var cloneLayer = Object.assign(
Object.create(Layer.prototype),
nestedLayer
);
if (path) cloneLayer.setPrefix(path);
if (router.opts.prefix) cloneLayer.setPrefix(router.opts.prefix);
router.stack.push(cloneLayer);
cloneRouter.stack[i] = cloneLayer;
}
...
}
return this;
}; This problem occurs in the above code when middlewares are bigger than nested layers. Unlike Router.prototype.use = function () {
...
for (var i = 0; i < middleware.length; i++) {
var m = middleware[i];
if (m.router) {
var cloneRouter = Object.assign(Object.create(Router.prototype), m.router, {
stack: m.router.stack.slice(0)
});
for (var i = 0; i < cloneRouter.stack.length; i++) {
var nestedLayer = cloneRouter.stack[i];
var cloneLayer = Object.assign(
Object.create(Layer.prototype),
nestedLayer
);
if (path) cloneLayer.setPrefix(path);
if (router.opts.prefix) cloneLayer.setPrefix(router.opts.prefix);
router.stack.push(cloneLayer);
cloneRouter.stack[i] = cloneLayer;
}
...
}
return this;
}; egaoneko@8828d7b#diff-504fd89f344be1e9c4b583f3ebd7428aL273 So I changed like the above code, it works. |
v8.0.8 released |
@egaoneko hahaha I can't believe I missed that nested I'll see if I can write a test for this particular section of code. Thanks for fixing my mistake 😄 |
@niftylettuce I think you missed releasing it on npm thou!, Would be appreciated :) |
It is released on npm. https://www.npmjs.com/package/@koa/router v8.0.8 I forgot to release the legacy version of koa-router, but just did so. |
node.js version: 10.16.0
npm/yarn and version: 1.17.3
@koa/router
version: 8.0.7koa
version: 2.11.0Error message:
Expected reason:
I tried to find the reason from the recent changes in PR(#50). I found some codes that expected bugs.
e07397c#diff-504fd89f344be1e9c4b583f3ebd7428aL262
In this refactoring, there are three
i
are declared and effected themself. I think it occurs infinite loop.e07397c#diff-504fd89f344be1e9c4b583f3ebd7428aR283
Before refactoring, In this section(
this[index] = cloneLayer
) refered toindex
. But after refatoring it chaged likecloneRouter.stack[i] = cloneLayer
.I wonder where the
index
has been referenced and why I changed it toi
.cc.
@JacobMGEvans
The text was updated successfully, but these errors were encountered: