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

Could not load worker TypeError: Failed to execute 'createObjectURL' on 'URL': No function was found that matched the signature provided. #240

Closed
dynastywind opened this issue Aug 1, 2017 · 9 comments

Comments

@dynastywind
Copy link

Problem

I'm using react-ace in my project but encounter a problem:

Could not load worker TypeError: Failed to execute 'createObjectURL' on 'URL': No function was found that matched the signature provided.
    at new WorkerClient (index.js:16800)
    at Mode.createWorker (javascript.js:1029)
    at EditSession.$startWorker (index.js:9120)
    at EditSession.$onChangeMode (index.js:9076)
    at EditSession.<anonymous> (index.js:9057)
    at AppConfig.exports.loadModule (index.js:3684)
    at EditSession.setMode (index.js:9046)
    at ReactAce.componentDidMount (ace.js:93)
    at ReactCompositeComponent.js:264
    at measureLifeCyclePerf (ReactCompositeComponent.js:75)

This problem only occur when I use modes that is related to javascript (javascript, coffee, etc.)

Sample code

import AceEditor from "react-ace";
import 'brace';
import 'brace/mode/javascript';
import 'brace/theme/github';

class Test extends React.Component<any, any> {
    render() {
        <AceEditor mode="javascript" theme="github" name="name" />
    }
}

I've tried everything I can come up with. Is there anyone who can help to solve this problem? Thanks!

@dynastywind
Copy link
Author

I solved this problem which is caused by a configuration in webpack.config.js.

@securingsincity
Copy link
Owner

@dynastywind do you mind adding what you changed in case others run into this issue?

@dynastywind
Copy link
Author

@securingsincity Sure.

I have below settings before with "mainFields" set to solve the commented problem. Actually it's copied from somewhere on Internet. This field breaks the working logic of react-ace's javascript-related modes. After I removed this field, my program is back to normal.

resolve: {
    extensions: ['.js', '.ts', '.tsx'],
    // Fix webpack's default behavior to not load packages with jsnext:main module
    // https://github.com/Microsoft/TypeScript/issues/11677
    mainFields: ['main']
}

@krutilin
Copy link

krutilin commented Aug 11, 2017

@securingsincity I faced the same issue. Is it possible to overcome it without modifying webpack.config? Because I have the project created using create-react-app and need to "eject" it to access webpack.config.
( the same issue is in the brace repo thlorenz/brace#54, but brace author said "needs to be fixed in Ace")

@hans-permana
Copy link

I observed the same warning message on my console, but did not encounter any actual issues when using react-ace editor. It may be that I have not used it rigorously enough to notice anything. Can anybody tell me if there is a noticeable issue that comes with this warning message?

@dynastywind
Copy link
Author

@hans-permana Can you still use syntax check in the editor after you find this warning? I remember that there was no error sign popping up if I type something illegal in a JS file.

@ShawnLin013
Copy link

Just found a workaround by adding following snippet to webpack config from thlorenz/brace#97

resolve: {
    mainFields: ["browser", "module", "main"]
},

@intrepidOlivia
Copy link
Contributor

intrepidOlivia commented Jul 18, 2018

Does anyone know if this was ever filed as an issue with Ace?

I'm running into this problem, but it's occurring during Mocha testing instead of normal rendering, and fiddling with the webpack doesn't fix it. :(

@joshyboyrules
Copy link

I'm running into this problem, but it's occurring during Mocha testing instead of normal rendering, and fiddling with the webpack doesn't fix it. :(

bump. running into the same issue w/ jest and testing-library/react :(

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

7 participants