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

regenerator global Function call throws CSP unsafe-eval error #639

Closed
rs178 opened this issue May 26, 2022 · 2 comments
Closed

regenerator global Function call throws CSP unsafe-eval error #639

rs178 opened this issue May 26, 2022 · 2 comments

Comments

@rs178
Copy link

rs178 commented May 26, 2022

Description : regenerator global Function call throws CSP unsafe-eval error

Steps to reproduce:

  1. file fetch-mock/es5/client-bundle.js has the following attached code
  2. client-bundle.js has global Function call which throws the unsafe-eval CSP error
  3. The above issue is fixed in CSP unsafe-eval in Web Worker in Chrome Browser which is always strict mode facebook/regenerator#450
  4. Need fetch-mock update to use the above latest regenerator fix to solve the issue
            try {
              regeneratorRuntime = runtime;
            } catch (accidentalStrictMode) {
              // This module should not be running in strict mode, so the above
              // assignment should always work unless something is misconfigured. Just
              // in case runtime.js accidentally runs in strict mode, we can escape
              // strict mode using a global Function call. This could conceivably fail
              // if a Content Security Policy forbids using Function, but in that case
              // the proper solution is to fix the accidental strict mode problem. If
              // you've misconfigured your bundler to force strict mode and applied a
              // CSP to forbid Function, and you're not willing to fix either of those
              // problems, please detail your unique predicament in a GitHub issue.
              Function("r", "regeneratorRuntime = r")(runtime);
            }
@Je12emy
Copy link

Je12emy commented Sep 20, 2022

I'm facing this same issue

@wheresrhys
Copy link
Owner

I have now rebuilt using more up to date build tools and hopefully this issue is now gone

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