Graphql-tag: Maximum call stack size exceeded

Created on 1 Oct 2020  Â·  2Comments  Â·  Source: apollographql/graphql-tag

Not sure what is causing this error or how to fix it, there's no feedback in the error-message.

|Environment|Version|
|--|--|
|node|v14.10.1|
|apollo-server-express|^2.17.0|
| fs-capacitor |^6.2.0|

import { GraphQLUpload } from "apollo-server-express";
import { createWriteStream } from "fs";
import { GraphQLScalarType } from "graphql";
import { Arg, Mutation, Resolver } from "type-graphql";
import { Stream } from "stream";

export interface Upload {
  filename: string;
  mimetype: string;
  encoding: string;
  createReadStream: () => Stream;
}

@Resolver()
export class UploadResolver {
  @Mutation(() => Boolean)
  async addProfilePicture(
    @Arg("file", () => GraphQLUpload as GraphQLScalarType)
    { createReadStream, filename }: Upload
  ): Promise<boolean> {
    console.log("file", filename); // ✅ MY_FILE.txt
    return await new Promise(async (resolve, reject) => {
      createReadStream()
        .pipe(createWriteStream(__dirname + `/images/${filename}`))
        .on("finish", () => resolve(true))
        .on("error", () => reject(false));
    });
  }
}

POST query in Postman: Body -> form-data
|key|value|
|---|---|
|operations|{"query":"mutation AddProfilePicture($file: Upload!) {\n addProfilePicture(file: $file)\n}"}|
|map|{ "testfile": ["variables.file"] }|
|testfile|MY_FILE.txt|

Terminal:

internal/fs/streams.js:131
  _openReadFs(this);
  ^

RangeError: Maximum call stack size exceeded
    at ReadStream.<anonymous> (internal/fs/streams.js:131:3)
    at ReadStream.deprecated [as open] (internal/util.js:89:15)
    at ReadStream.open (C:\git\fullstack\node_modules\apollo-server-core\node_modules\fs-capacitor\lib\index.js:90:11)
    at _openReadFs (internal/fs/streams.js:138:12)
    at ReadStream.<anonymous> (internal/fs/streams.js:131:3)
    at ReadStream.deprecated [as open] (internal/util.js:89:15)
    at ReadStream.open (C:\git\fullstack\node_modules\apollo-server-core\node_modules\fs-capacitor\lib\index.js:90:11)
    at _openReadFs (internal/fs/streams.js:138:12)
    at ReadStream.<anonymous> (internal/fs/streams.js:131:3)
    at ReadStream.deprecated [as open] (internal/util.js:89:15)

Any help is highly appreciated. Thanks.

Most helpful comment

I solved it by downgrading my node.js

All 2 comments

Had a similar issue a while back, can't remember the exact steps
But basically, it has to do with the fs-capacitor not matching with the version of node you have

I solved it by downgrading my node.js

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ryanjsmyth picture ryanjsmyth  Â·  5Comments

codepunkt picture codepunkt  Â·  7Comments

dallonf picture dallonf  Â·  6Comments

hopewise picture hopewise  Â·  8Comments

matheusrocha89 picture matheusrocha89  Â·  6Comments