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

[BUG] Cross origin worker script fails to load for static site #2403

Closed
1 task done
ferdaarikan opened this issue Jan 16, 2024 · 5 comments · Fixed by #2492
Closed
1 task done

[BUG] Cross origin worker script fails to load for static site #2403

ferdaarikan opened this issue Jan 16, 2024 · 5 comments · Fixed by #2492

Comments

@ferdaarikan
Copy link

ferdaarikan commented Jan 16, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Similar to #1254 and also mentioned here graphql-dotnet/server#1110

When pre-request or post-request scripts are enabled worker fails to initialise and scripts do not run.

image

Expected Behavior

Pre/Post request script to execute without errors

Steps To Reproduce

The fiddle provided in issue #1254 https://jsfiddle.net/imolorhe/zrjh2x08/27/ also reproduces the same issue. Try a simple schema query when post or pre request script is enabled and populated.
https://jsfiddle.net/imolorhe/zrjh2x08/27/

js fiddle output:
image

Environment

- OS:Windows 10
- Browser: Firefox 121.0.1 and Chrome 120.0.6099.217
- Platform: embedded into asp.net core app
- Version: npm package via cdn.jsdelivr.net

Additional context

No response

@imolorhe
Copy link
Collaborator

I'm attempting to fix this issue. In the meantime you can disable the beta version of the scripts and fallback to the old behavior to unblock yourself (although I would recommend enabling the beta version again when you're done since eventually that would be the only option, and it would be good to know that it still works as expected for you).

@imolorhe
Copy link
Collaborator

The last fix didn't work because angular has disabled processing import.meta.url pattern for fetching assets at runtime, so will need to figure out another way to get the compiled JS file path for the web worker.

@imolorhe
Copy link
Collaborator

Ooh.. actually this might work.

@imolorhe
Copy link
Collaborator

Okay this issue requires a different solution. We may have to move away from using web workers as they are very strict with enforcing the same origin policy of the browser. The above solutions don't work because the web worker scripts are complex enough that loading them via blobs don't work.

@imolorhe
Copy link
Collaborator

imolorhe commented Apr 29, 2024

This should be fixed now in v7.0.1. Can you verify?

Actually it still wouldn't work just yet, since we expect a trusted origin. I'll remove that check in the next release.

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

Successfully merging a pull request may close this issue.

2 participants