jaydenseric / graphql-upload

Middleware and a scalar Upload to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers.
https://npm.im/graphql-upload
MIT License
1.43k stars 132 forks source link

Maximum call stack size exceeded, using version 11.0.0 with Node 14.16.0 and Federation #244

Closed forkitupforkitup closed 3 years ago

forkitupforkitup commented 3 years ago

Hello,

When I npm ls graphql-upload:

apollofederation@1.0.0 /home/ian/Sites/project-gnosis/apollofederation
└── graphql-upload@11.0.0 

Here is my React Uploader component, I tried to follow the instructions on the README for using a File:

const Uploader = () => {
    const uploadMessage = 'Finally, please upload a PDF:';

    function onChange({ target: { validity, files: [file] } }) {
      if (validity.valid) uploadPDF({ variables: { file } });
    }

    return (
      <form encType="multipart/form-data">
        <label htmlFor="uploadButton">{uploadMessage}</label>
        <input
          name="uploadButton"
          type="file"
          accept=".pdf"
          // ref={pdfInput}
          onChange={onChange}
        />
        <button type="submit">upload</button>
      </form>
    );
  };
2021-04-14T15:13:55.260Z error:     uncaughtException: Maximum call stack size exceeded
[server:gateway] RangeError: Maximum call stack size exceeded
[server:gateway]     at ReadStream.deprecated [as open] (internal/util.js:74:22)
[server:gateway]     at ReadStream.open (/home/ian/Sites/project-gnosis/apollofederation/node_modules/fs-capacitor/lib/index.js:90:11)
[server:gateway]     at _openReadFs (internal/fs/streams.js:138:12)
[server:gateway]     at ReadStream.<anonymous> (internal/fs/streams.js:131:3)
[server:gateway]     at ReadStream.deprecated [as open] (internal/util.js:89:15)
[server:gateway]     at ReadStream.open (/home/ian/Sites/project-gnosis/apollofederation/node_modules/fs-capacitor/lib/index.js:90:11)
[server:gateway]     at _openReadFs (internal/fs/streams.js:138:12)
[server:gateway]     at ReadStream.<anonymous> (internal/fs/streams.js:131:3)
[server:gateway]     at ReadStream.deprecated [as open] (internal/util.js:89:15)
[server:gateway]     at ReadStream.open (/home/ian/Sites/project-gnosis/apollofederation/node_modules/fs-capacitor/lib/index.js:90:11)
[server:gateway] (node:14701) [DEP0135] DeprecationWarning: ReadStream.prototype.open() is deprecated
[server:gateway] (Use `node --trace-deprecation ...` to show where the warning was created)

Thank you very much.

mike-marcacci commented 3 years ago

Hi @forkitupforkitup, what version of fs-capacitor do you have? The stack trace makes me think this is an old version, from before node 14 was released.

forkitupforkitup commented 3 years ago

Hi @forkitupforkitup, what version of fs-capacitor do you have? The stack trace makes me think this is an old version, from before node 14 was released.

Hello @mike-marcacci, after investigating I found I was still on the version of fs-capacitor that came with Apollo Server, around version 2. I set uploads to false in my Apollo Server constructor and reinstalled everything and I'm on the latest version of fs-capacitor now. That seems to have worked. Thanks.

mike-marcacci commented 3 years ago

Happy to help, and glad it was an easy fix!