Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

OOM issue when writing to nodejs-storage writeStream #489

@jkwlui

Description

@jkwlui

cc-ed from internal ticket.

const {Storage} = require("@google-cloud/storage");
const gcs = new Storage({projectId: "test-1"});
const crypto = require("crypto");
const file = gcs.bucket("test-bucket").file("test");
const ws = file.createWriteStream({resumable: false}); // must be false

ws.on("error", console.error);
ws.on("finish", () => console.log("finish"));
ws.end(crypto.randomBytes(28e6));

Steps to Reproduce

For latest version:

  1. Create a .js file containing the command above
  2. Run the command node [FILENAME].js

Error

ivanlindoubeda@cloudshell:~ (hcl-ivanlindoubeda)$ node repro.js
<--- Last few GCs --->
 
[1277:0x3c0ea30]     8479 ms: Mark-sweep 333.3 (353.3) -> 333.3 (353.8) MB, 150.7 / 0.0 ms  (+ 35.8 ms in 1 steps since start of marking, biggest step 35.8 ms, walltime since start of marking 4972 ms) allocation failure GC in old space requested
 
 
<--- JS stacktrace --->
 
==== JS stack trace =========================================
 
Security context: 0x1bcbac825ee1 <JSObject>
    2: replaceProjectIdToken(aka replaceProjectIdToken) [/home/ivanlindoubeda/node_modules/@google-cloud/projectify/build/src/index.js:44] [bytecode=0x193e392eaa9 offset=72](this=0x2d02d8a02311 <undefined>,value=0x25688ced7ee1 <Uint8Array map = 0x15d55936bdf1>,projectId=0x2841cf0ccf21 <String[18]: hcl-ivanlindoubeda>)
    4: replaceProjectIdToken(aka replaceProjectIdToken) [/home/ivanlindoubeda/...
 
FATAL ERROR: invalid table size Allocation failed - JavaScript heap out of memory
 1: node::Abort() [node]
 2: 0x121a2cc [node]
 3: v8::Utils::ReportOOMFailure(char const*, bool) [node]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
 5: v8::internal::OrderedHashTable<v8::internal::OrderedHashSet, 1>::Allocate(v8::internal::Isolate*, int, v8::internal::PretenureFlag) [node]
 6: v8::internal::OrderedHashTable<v8::internal::OrderedHashSet, 1>::Rehash(v8::internal::Handle<v8::internal::OrderedHashSet>, int) [node]
 7: v8::internal::OrderedHashTable<v8::internal::OrderedHashSet, 1>::EnsureGrowable(v8::internal::Handle<v8::internal::OrderedHashSet>) [node]
 8: v8::internal::OrderedHashSet::Add(v8::internal::Handle<v8::internal::OrderedHashSet>, v8::internal::Handle<v8::internal::Object>) [node]
 9: v8::internal::KeyAccumulator::AddKey(v8::internal::Handle<v8::internal::Object>, v8::internal::AddKeyConversion) [node]
10: 0xe11e57 [node]
11: v8::internal::KeyAccumulator::CollectOwnElementIndices(v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::JSObject>) [node]
12: v8::internal::KeyAccumulator::CollectOwnKeys(v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::JSObject>) [node]
13: v8::internal::KeyAccumulator::CollectKeys(v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::JSReceiver>) [node]
14: v8::internal::FastKeyAccumulator::GetKeys(v8::internal::GetKeysConversion) [node]
15: 0x10bf8b4 [node]
16: v8::internal::Runtime_ForInPrepare(int, v8::internal::Object**, v8::internal::Isolate*) [node]
17: 0x39fed190e6a5
Aborted (core dumped)

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.api: storageIssues related to the googleapis/nodejs-storage API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions