Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Current version(8.0.7) make Out Of Memory

See original GitHub issue

node.js version: 10.16.0

npm/yarn and version: 1.17.3

@koa/router version: 8.0.7

koa version: 2.11.0

Error message:

<--- Last few GCs --->

[60877:0x102b00000]    35217 ms: Mark-sweep 1387.5 (1416.2) -> 1387.5 (1416.2) MB, 1598.4 / 0.0 ms  (average mu = 0.095, current mu = 0.000) last resort GC in old space requested
[60877:0x102b00000]    36649 ms: Mark-sweep 1387.5 (1416.2) -> 1387.5 (1416.2) MB, 1432.6 / 0.0 ms  (average mu = 0.058, current mu = 0.000) last resort GC in old space requested

<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x3557fc5be3d]
Security context: 0x13a08dc1e6e9 <JSObject>
    1: /* anonymous */ [0x13a0aa29e261] [/Users/user/Documents/workspace/my-project/@koa/router/lib/router.js:~246] [pc=0x3558022e30f](this=0x13a0c2a0be31 <Router map = 0x13a0a2f5da09>)
    2: arguments adaptor frame: 25->0
    3: /* anonymous */(aka /* anonymous */) [0x13a0c24028d9] [0x13a0d3c026f1 <undefined>:30] [bytecode=0x13a00c60dcd...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: 0x10003cf99 node::Abort() [/Users/user/.nvm/versions/node/v10.16.0/bin/node]
 2: 0x10003d1a3 node::OnFatalError(char const*, char const*) [/Users/user/.nvm/versions/node/v10.16.0/bin/node]
 3: 0x1001b7835 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/user/.nvm/versions/node/v10.16.0/bin/node]
 4: 0x100585682 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/user/.nvm/versions/node/v10.16.0/bin/node]
 5: 0x10058eb84 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/Users/user/.nvm/versions/node/v10.16.0/bin/node]
 6: 0x10055de86 v8::internal::Factory::NewFixedArrayWithFiller(v8::internal::Heap::RootListIndex, int, v8::internal::Object*, v8::internal::PretenureFlag) [/Users/user/.nvm/versions/node/v10.16.0/bin/node]
 7: 0x1005052ae v8::internal::(anonymous namespace)::ElementsAccessorBase<v8::internal::(anonymous namespace)::FastPackedObjectElementsAccessor, v8::internal::(anonymous namespace)::ElementsKindTraits<(v8::internal::ElementsKind)2> >::GrowCapacity(v8::internal::Handle<v8::internal::JSObject>, unsigned int) [/Users/user/.nvm/versions/node/v10.16.0/bin/node]
 8: 0x1007a06bf v8::internal::Runtime_GrowArrayElements(int, v8::internal::Object**, v8::internal::Isolate*) [/Users/donghyun/.nvm/versions/node/v10.16.0/bin/node]
 9: 0x3557fc5be3d
10: 0x3558022e30f

Expected reason:

I tried to find the reason from the recent changes in PR(#50). I found some codes that expected bugs.


In this refactoring, there are three i are declared and effected themself. I think it occurs infinite loop.


Before refactoring, In this section(this[index] = cloneLayer) refered to index. But after refatoring it chaged like cloneRouter.stack[i] = cloneLayer.

I wonder where the index has been referenced and why I changed it to i.

cc. @JacobMGEvans

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

JacobMGEvanscommented, Feb 9, 2020

@egaoneko hahaha I can’t believe I missed that nested for loop nice catch and fix! 🎉

I’ll see if I can write a test for this particular section of code. Thanks for fixing my mistake 😄

egaonekocommented, Feb 8, 2020

@JacobMGEvans Oh, I miss watched about index with forEach. When I tested it, It does not occured with just koa and router. We use koa with Next.js, TypeScript, Webpack. I try to make a sample code for it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jira 8.0 server version - consuming all memory of server
Java is consuming all memory. It would be difficult to say what is going on without some sort of tool that is analysing...
Read more >
commit issues - LIVEcommunity - 174065
Anyone else getting: Error: Error reading tom data failed to handle CONFIG_UPDATE_START (Module: device) Commit failed Issue been logged - 174065.
Read more >
Java SDK fixes, version 8.0 - IBM
Read more >
Memory Leak - traffic_ctl config reload · Issue #4562 - GitHub
Hi, I have noticed that the trafficserver's memory usage is increasing with each config reload. After each config reload it's allocating ...
Read more >
PHP 8 ChangeLog
Updated the mime-type table for the builtin-server. ... Fixed bug GH-9801 (Generator crashes when memory limit is exceeded during ... Version 8.0.7.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found