Code Monkey home page Code Monkey logo

Comments (7)

bglw avatar bglw commented on June 24, 2024 1

Agreed that it isn't great. There is some chatter around adding a wasm-src CSP and verifying these files, so I'll check on the status of that in the future. I'll also add a note to the documentation.

from pagefind.

bglw avatar bglw commented on June 24, 2024

Oops. So it looks like this fetch is failing on line 55: search.js > loadWasm

Unfortunately there's a bug in the catch on line 61 trying to log url which is suppressing the actual error đŸ¤Ļ

I'll fix up that log locally and then see if I can reproduce the CSP error. I don't see why a connect-src 'self' would block a fetch("/_pagefind/wasm.pagefind") request — my suspicions would be it doesn't like the fetch occurring inside an ES6 module, or it doesn't like the fetch of a file without any sane content type 🤔

Keen to hear if you have any ideas on where to look, otherwise I'll keep you posted on what I dig up 🙂

Cheers!

from pagefind.

vanbroup avatar vanbroup commented on June 24, 2024

I don't think the call is blocked by the CSP as that would give a clear error message, but some context/meta-data might not be provided with this CSP enabled, causing the script to fail.

Sorry, I haven't looked at it in detail yet.

from pagefind.

bglw avatar bglw commented on June 24, 2024

Ah, I see where our issue lays. If I suppress that url error, I get:

CompileError: call to WebAssembly.instantiate() blocked by CSP

Unfortunately (I'm just now learning that) wasm broadly currently gets classified under unsafe-eval.

In the past the only path to get that working has been to allow script-src 'unsafe-eval' in your CSP. There is however a proposal to add a wasm-specific CSP to browsers, which adds a specific script src wasm-unsafe-eval. It's hard to tell how broadly this is supported, but looking at Chrome it appears this has shipped, and testing it in Firefox myself it does work.

So adding script-src 'wasm-unsafe-eval' to your CSP should allow wasm to execute without adding extra permissions to your js.

from pagefind.

bglw avatar bglw commented on June 24, 2024

Bad news — my test site doesn't work in Safari without script-src 'unsafe-eval' ☚ī¸ Looks like wasm-unsafe-eval is on the way for Webkit but isn't stable yet.

from pagefind.

vanbroup avatar vanbroup commented on June 24, 2024

Setting script-src 'wasm-unsafe-eval' looks to 'solve' the problem for Chrome, Edge and Firefox on both desktop and mobile. It would be great if we don't have to allow any unsafe policies however, unfortunately this does currently seem to be a requirement for WebAssembly.

from pagefind.

bglw avatar bglw commented on June 24, 2024

I have covered this point in the documentation alongside the latest release, so I'll close this issue for now and keep an eye on CSP/WASM goings on.

from pagefind.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.