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.
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
Most helpful comment
I solved it by downgrading my node.js