-
Notifications
You must be signed in to change notification settings - Fork 178
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
Uncaught ReferenceError: REPLConsole is not defined #240
Comments
A bit more information: I'm on Rails 5.0.0.1, so my Rails development server is Puma:
I ensured that the cause was not being on the web-console IP whitelisted (i.e. I don't see the log message that gets shown when you hit the app from a non-local IP address) |
Hey, it should just work. Can you give me a bit more context? Maybe what kind of gems you have installed and the full browser console log? |
@gsamokovarov Thanks for taking a look at this. I upgrade to Rails 5.1.1 and web-console 3.5.1, and I'm still seeing this. When I insert When I insert Other gem versions, I'm not sure which might be relevant:
My config/initializers/assets.rb # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
Rails.application.config.assets.precompile += %w(
admin.js admin.css
application-onboarding.js application-onboarding.css
react-server.js components.js
google_analytics/campaign-loader.js
)
Rails.application.config.assets.paths << Rails.root.join("vendor", "assets")
Rails.application.config.assets.precompile << %r(Font-Awesome/fonts/[\w-]+\.(?:otf|eot|svg|ttf|woff|woff2?)$) I also spent a bunch of time messing with other gems in my How is the REPLConsole JavaScript object supposed to make it onto the page? Could there be some oversight on my part or in the gem where that front-end asset isn't being included correctly? I don't know what the "Invalid or unexpected token" message is referring to, but by Googling/StackOverflowing it looks like that error can happen if bad characters make their way to Chrome, so it could be some problem with asset compilation? Not sure. Thanks again. Let me know if any more info would be helpful. |
More digging in Safari, which seems to provide better errors: The first error, The second error, ![use__magic_link__approach_for_authentication_by_kdeggelman_ pull_request__2240 _firstroundcapital_network(https://cloud.githubusercontent.com/assets/107841/26220380/3b4d3862-3bc7-11e7-8e9c-1aee75bd450f.png) The third error, FWIW I'm also using Turbolinks 5.0.1, but I don't think this is happening late enough in the requests cycle for Turbolinks to be messing with anything. The first error looks like the cause to me, somehow the rendered HTML has JavaScript with an unclosed string var consoleInnerHtml = "<div class='resizer layer'><\/div> |
I just looked at this for 2 hours and I think it might be a regression with Rails 5.1 or a bad assumption about the capabilities of JavaScript escaping within ERB/rendering. The problem is that the gem ends up outputting JavaScript onto the page that has a line break in it, which is not supported by JavaScript. That results in the Here's the files I'm looking at to determine what's going on:
I believe that web-console is either making faulty assumptions about how JavaScript is being escaped by This multi-line JavaScript string problem happens with the following variables:
Hopefully this helps. There might be an easy way to fix it by rendering the templates a bit differently, but after a few hours of messing with it I couldn't get it quite right without using ES6 template literals. I'm not sure why the newlines aren't being removed correctly, and there are multiple levels of rending going on so it's hard to track. Thanks for the time you put into this gem. |
Temporary fix, see rails#240 for more details.
@aguynamedben thanks for the investigation. I'm pretty curious why this happens only to you know. I would have expected a lot more reports about that. Is your |
@gsamokovarov It's for a private project, so I just emailed it to you. I'll post any further updates to this thread though. Thanks for helping me look into it. |
I'm seeing the same issue on Rails 5.1.4 the fix above works: aguynamedben@73d0cd0 |
Fix js string error - closes #240
I'm trying to switch my project from better_errors to web-console. When I install web-console 3.5.0 and try to use
<% console %>
or generate an error page, the error page shows up without any REPL available. In my JavaScript console I see this error:Uncaught ReferenceError: REPLConsole is not defined
It looks like REPLConsole is a JavaScript library downloadable via NPM. I don't see anything in the web-console documentation telling me I need to install/configure any JavaScript assets. Do I need to include another gem or add a line to my application.js to get REPLConsole to be present? Should it "just work"?
Thanks for your work on this gem, I've heard it's faster that better_errors and am looking forward to switching.
The text was updated successfully, but these errors were encountered: