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

Add require stringio #31

Merged
merged 1 commit into from
Apr 4, 2022
Merged

Conversation

bongole
Copy link
Contributor

@bongole bongole commented Apr 3, 2022

Fix StringIO Exception when using serverless offline with simple rack application.

Steps to reproduce

  • Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '~> 2.7'

gem 'rack'
  • config.ru
class TestApp
  def call(env)
    status  = 200
    headers = { "Content-Type" => "text/html" }
    body    = ["Hello World!"]

    [status, headers, body]
  end
end

run TestApp.new
  • serverless.yml
service: sls-test
frameworkVersion: '3'

provider:
  name: aws
  runtime: ruby2.7

functions:
  api:
    handler: rack_adapter.handler
    events:
      - http: GET /

plugins:
  - serverless-rack
  - serverless-offline
$ sls rack install
$ sls offline
$ curl http://localhost:3000/dev
...
GET /dev (λ: api)
✖ Command failed with exit code 1: ruby /home/bongole/dev/sls-test/node_modules/serverless-offline/dist/lambda/handler-runner/ruby-runner/invoke.rb rack_adapter handler
  /home/bongole/dev/sls-test/serverless_rack.rb:100:in `build_environ': uninitialized constant StringIO (NameError)
        from /home/bongole/dev/sls-test/serverless_rack.rb:227:in `handle_request'
        from /home/bongole/dev/sls-test/rack_adapter.rb:63:in `handler'
        from /home/bongole/dev/sls-test/node_modules/serverless-offline/dist/lambda/handler-runner/ruby-runner/invoke.rb:83:in `<main>'

@logandk logandk merged commit b32cffe into logandk:master Apr 4, 2022
@logandk
Copy link
Owner

logandk commented Apr 4, 2022

Thanks, @bongole!

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.

2 participants