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

Enable binmode for IO pipes #2527

Merged
merged 1 commit into from
Mar 9, 2023
Merged

Conversation

bgastelo
Copy link
Contributor

@bgastelo bgastelo commented Mar 9, 2023

While setting up the Chrome runner for opal-rspec, I came across this error message with the builder:

# bundle exec rake
rake aborted!
Encoding::UndefinedConversionError: "\xFD" from ASCII-8BIT to UTF-8
/usr/local/bundle/gems/opal-1.7.2/lib/opal/builder_scheduler/prefork.rb:170:in `write'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/builder_scheduler/prefork.rb:170:in `send_message'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/builder_scheduler/prefork.rb:195:in `send'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/builder_scheduler/prefork.rb:270:in `block (2 levels) in prefork_reactor'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/builder_scheduler/prefork.rb:262:in `each'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/builder_scheduler/prefork.rb:262:in `block in prefork_reactor'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/builder_scheduler/prefork.rb:259:in `loop'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/builder_scheduler/prefork.rb:259:in `prefork_reactor'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/builder_scheduler/prefork.rb:17:in `process_requires'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/builder.rb:216:in `process_requires'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/builder.rb:107:in `build_str'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/builder.rb:92:in `build'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/cli.rb:135:in `block in create_builder'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/cli.rb:135:in `each'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/cli.rb:135:in `create_builder'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/cli.rb:94:in `block in run'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/cli_runners/chrome.rb:31:in `initialize'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/cli_runners/chrome.rb:19:in `new'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/cli_runners/chrome.rb:19:in `call'
/usr/local/bundle/gems/opal-1.7.2/lib/opal/cli.rb:96:in `run'
/usr/local/bundle/gems/opal-rspec-1.0.0/lib/opal/rspec/runner.rb:141:in `run'
/usr/src/app/Rakefile:12:in `block in <top (required)>'
/usr/local/bundle/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => default
(See full trace by running task with --trace)

Since the code is using Marshal to pass data through the IO pipe, it expects to be in the ASCII-8BIT encoding. It would make sense then that we set binmode on the IO pipes so that they don't get confused with the string encoding.

Sorry for not including any tests, since I'm having trouble figuring out exactly what input causes it. It seems to work sometimes with a simple example, but loading more files causes it to crash? I'm not too sure.

I have an example repo here: https://github.com/bgastelo/example-opal-rspec-async where it is occurring. I've stepped through my debugger but I must be missing what causes it.

This is my first PR, so let me know if there is anything I can do to update my PR.

Thanks,

Brandon

@hmdne
Copy link
Member

hmdne commented Mar 9, 2023

Thanks! Encoding is always a tricky thing to get right... :(

@hmdne hmdne merged commit 16055fe into opal:master Mar 9, 2023
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

Successfully merging this pull request may close these issues.

None yet

2 participants