Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error The script will never generate a response on Cloudflare Worker when using mesh #5112

Closed
4 tasks
abby-ran opened this issue Feb 7, 2023 · 9 comments
Closed
4 tasks

Comments

@abby-ran
Copy link

abby-ran commented Feb 7, 2023

### Issue workflow progress

Progress of the issue based on the
Contributor Workflow

Make sure to fork this template and run yarn generate in the terminal.

Please make sure Mesh package versions under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

We have a POC of a graphql gateway using the mesh library on a Cloudflare worker.
When running performance testing we notices a lot of these errors: The script will never generate a response.
On research of this error we think this is due to meshInstance$ being a global variable and several requests trying to access it at the same time, and they fail with a failed Promise error. I see this error in the console log:
A hanging Promise was canceled. This happens when the worker runtime is waiting for a Promise from JavaScript to resolve, but has detected that the Promise cannot possibly ever resolve because all code and events related to the Promise's I/O context have already finished.
Our worker code is very simple, this is the index.ts:

import { createBuiltMeshHTTPHandler } from '../.mesh';
self.addEventListener('fetch', createBuiltMeshHTTPHandler());

with a few online API graphql endpoints in our yaml file

To Reproduce Steps to reproduce the behavior:

Create a new mesh gateway and with that index.ts and load to a Cloudflare worker using wrangler.

Expected behavior

Being able to run a load test without having these unresolved Promise errors

Environment:
"wrangler": "2.8.0",
"@graphql-mesh/cli": "^0.82.10",
"@graphql-mesh/graphql": "^0.33.8",
"@graphql-mesh/runtime": "^0.46.5",
"@graphql-mesh/transform-resolvers-composition": "^0.13.5",
"graphql": "^16.6.0",
"http-status-codes": "^2.2.0",
"envelop": "^1.4.0"

  • OS:
  • @graphql-mesh/...:
  • NodeJS:
    v18.13.0

Additional context

This is very similar to this issue but no solution was offered

@tv42
Copy link

tv42 commented Feb 10, 2023

I'd assume this is https://zuplo.com/blog/the-script-will-never-generate-a-response-on-cloudflare-workers/

I haven't yet sorted what hoops to jump through to avoid this. Seems really hard to write e.g. in-memory caching with this limitation.

@abby-ran
Copy link
Author

We found that the node compatibility was causing this, once we removed it we haven't seen any errors. We moved to using plugins instead of transforms in the yaml file for our mesh gateway, so we didn't need the node compatibility anymore!

@ardatan
Copy link
Owner

ardatan commented Feb 13, 2023

Awesome! So we can close this issue then!

@abby-ran
Copy link
Author

Yes this is solved for us, thanks :)

@ardatan
Copy link
Owner

ardatan commented Feb 13, 2023

Do you think we should mention that in our docs?

@abby-ran
Copy link
Author

That would be great.
There seems to be an issue with that node compatibility, it would be great to have a note in the docs that this causes errors when running the mesh on a CF worker

@ardatan
Copy link
Owner

ardatan commented Feb 13, 2023

Would you contribute to our docs with a PR because I think the words from your perspective would be better :)

@abby-ran
Copy link
Author

yeah sure :) which doc\file should I add this too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants