developit / greenlet

🦎 Move an async function into its own thread.
https://npm.im/greenlet
4.67k stars 100 forks source link

Firefox doesn't support comments in provided async function #32

Closed JamesLMilner closed 4 years ago

JamesLMilner commented 6 years ago

More just an observation than a bug; Firefox doesn't appear to handle comments inside of the passed async function. This appears to be because it puts all the code onto one line which causes the parsing to break via a SyntaxError i.e.:

SyntaxError: missing } after function body
data:$$=async%20(data,%20stringify)%20=>%20{//%20Commentif%20(stringify)%20{data%20=%20JSON.parse(da:1:416
note: { opened at line 1, column 30

in short, this will cause an error:

    const exampleAsyncFunc = async (data) => {
            // A wild comment appears
        return data
    }

but this does not:

    const exampleAsyncFunc = async (data) => {
        return data
    }
developit commented 6 years ago

Looks like the fix here is to just manually encode the URI instead of letting the browser do it. We could potentially even just apply it to asyncFunction here: https://github.com/developit/greenlet/blob/d8467e0f45049dd71ee899dd73093d5137e41435/greenlet.js#L15

developit commented 6 years ago

Update: if we switch back to Blob URLs to address the CSP issues, this error goes away.

developit commented 4 years ago

This is fixed by #38.