EinYs
0
EinYs
commented 13 days ago

Version

5.0.0

Reproduction link

https://github.com/EinYs/nuxt-axiosTest

Steps to reproduce

  1. excute 'npm run dev'
  2. go to http://localhost:3000

What is expected ?

index page to be opened

What is actually happening?

Memory leak and crash

Additional comments?

Tested version 5.0.0 ,5.3.2 ,5.3.4 and that all got a memory leak error. The linked is with v5.3.2

If nuxt/axios module and config is removed from nuxt.config.js file, app will not make errors.

my nodejs version is v10.9.0


Attaching my memory crash log

<--- Last few GCs --->

[18052:000001B62E87F9E0] 70021 ms: Mark-sweep 1353.0 (1456.9) -> 1352.9 (1456.9) MB, 1358.3 / 0.6 ms (average mu = 0.082, current mu = 0.000) allocation failure GC in old space requested
[18052:000001B62E87F9E0] 71405 ms: Mark-sweep 1352.9 (1456.9) -> 1352.7 (1426.4) MB, 1383.5 / 0.8 ms (average mu = 0.042, current mu = 0.001) last resort GC in old space requested

<--- JS stacktrace --->

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

0: ExitFrame [pc: 0000004F69EDC6C1]

Security context: 0x03abdc49e549 <JSObject>
1: _extend [0000017716F12E01] [util.js:~1253] [pc=0000004F6A511ABF](this=0x01a11f203f89 <Object map = 000000536F8B26C1>,target=0x0177de472739 <Object map = 000000536F882571>,source=0x0177de473e71 <Object map = 000002011DF0F301>)
2: new constructor(aka Socket) [0000021000907DF1] [net.js:239] [bytecode=0000017716F42EC1 offset=118](this=0x0177de472641…

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 00007FF69D733D05
2: 00007FF69D70DD46
3: 00007FF69D70E610
4: 00007FF69DB748DE
5: 00007FF69DB7480F
6: 00007FF69DAC01A4
7: 00007FF69DAB6747
8: 00007FF69DAB4CBC
9: 00007FF69DAB4155
10: 00007FF69DABDDA4
11: 00007FF69DBE3388
12: 00007FF69DBE964A
13: 00007FF69DAF0B94
14: 00007FF69D9C9B0E
15: 00007FF69D9C9C66
16: 00007FF69D9CBE1B
17: 00007FF69D9BABD4
18: 00007FF69D9CB209
19: 00007FF69D99816E
20: 00007FF69D9BED41
21: 00007FF69DC62B71
22: 00007FF69DC65C08
23: 0000004F69EDC6C1
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! [email protected] dev: node api/server.js
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

bug
0
pi0
19.8k
pi0
commented 13 days ago

@EinYs From the example that you provided, it seems baseURL is set wrong (Port is same as Nuxt but no /api endpoint registered)

axios: {
    baseURL: 'http://127.0.0.1:3000/api/v1'
  },

http://127.0.0.1:3000/api/v1 points to the same Nuxt.js webserver, combining with auth that tried to call auth route it makes an infinite loop.

Solutions:

  • Use proxy option to proxy /api requests to an external API
  • Manually register serverMiddleware on /api
  • set baseURL to point to API server

BTW sorry for inconveniences. We may have to somehow detect and make warns about such loops. I'll update the Issue title.

0
EinYs
0
EinYs
commented 13 days ago

I see. Thank you for giving solution

0
Informations
Bug ReportOpen
#c193 - Created 13 days ago