0

Purpose

I want to use mysql2 (npm).

Steps

  1. Install MySQL by brew install mysql, set up to make sure I can login by mysql -r root -p
  2. Run npm init and npm install mysql2 --save
  3. Create index.js (see below)
  4. Run node index.js
  5. See an error below.

Steps (to check whether mysql2 causes the issue)

  1. Comment out the second line of index.js
  2. Run node index.js
  3. Confirm that Terminal shows "BEFORE" and "AFTER" without an error.

index.js

console.log('BEFORE');
const mysql = require('mysql2');
console.log('AFTER');

Console (error message)

BEFORE

<--- Last few GCs --->

[3203:0x150008000]       34 ms: Scavenge 2.8 (4.6) -> 2.5 (5.3) MB, 0.5 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure 
[3203:0x150008000]       42 ms: Scavenge 3.8 (7.8) -> 3.5 (8.5) MB, 0.3 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure 

<--- JS stacktrace --->

FATAL ERROR: wasm code commit Allocation failed - process out of memory
1: 0x1040fe9d8 node::Abort() [/Users/{MY_USER_NAME}/.nvm/versions/node/v14.15.5/bin/node]
...
63: 0x10492c1e8 Builtins_JSEntry [/Users/{MY_USER_NAME}/.nvm/versions/node/v14.15.5/bin/node]
64: 0x150008000 
zsh: abort      node index.js

Environment

  • Mackbook Air (M1, 2020)
  • macOS: 11.2.2
  • node: 14.15.5
  • npm: 7.6.1
  • mysql2 (npm): 2.2.5
  • mysql (brew): Ver 8.0.23 for osx10.16 on x86_64 (Homebrew)
dmjy
  • 1,183
  • 3
  • 10
  • 26
  • I’m voting to close this question because it's likely irrelevant. Software has stabilized after a few months. – Evert May 03 '21 at 00:03

1 Answers1

0

I had the same issue. Upgrading from node v14 to v15 resolved it.

  • 1
    Welcome to StackOverflow! I recommend against rhetoric questions in answers. They risk being misunderstood as not an answer at all. You are trying to answer the question at the top of this page, aren't you? Otherwise please delete this post. – Yunnosch Apr 28 '21 at 07:53
  • I had a similar issue using Node V14.16.1 on M1 chip and it was NOT fixed by using node v15.7.0, keeping all other things the same - so for me, upgrade to V15 was not a solution – NULL pointer May 01 '21 at 21:05