0

I have a very difficult to debug error after upgrading to Rails 7 from 6.1.

It would appear the pages that are not controlled by devise authentication are behaving just fine. When the user is redirected or visits the auth page directly, this error shows it's face.

I have read quite a few threads but they all seem pretty unrelated. Any suggestions for logs or other places to start diggin?

Apache Log

[Wed Mar 22 15:29:36.670330 2023] [core:error] [pid 95707] [client 127.0.0.1:52600] Premature end of script headers: users
[Wed Mar 22 16:20:31.688989 2023] [core:error] [pid 95708] [client 127.0.0.1:65362] Premature end of script headers: users

Rails Log

Started GET "/users" for 127.0.0.1 at 2023-03-22 16:23:32 -0700
Processing by Lux::UsersController#index as HTML
Completed 401 Unauthorized in 11ms (Allocations: 2857)


Started GET "/users/sign_in" for 127.0.0.1 at 2023-03-22 16:23:32 -0700
Processing by Lux::SessionsController#new as HTML
  Rendering layout layouts/user.html.erb
  Rendering devise/sessions/new.html.erb within layouts/user
  Rendered devise/sessions/new.html.erb within layouts/user (Duration: 6.2ms | Allocations: 1492)
  Rendered layout layouts/user.html.erb (Duration: 625.5ms | Allocations: 555283)
Completed 200 OK in 631ms (Views: 626.4ms | Allocations: 558289)

Lux::SessionsController

class Lux::SessionsController < ::Devise::SessionsController
end

From what I can tell, the app logs look completely normal. Everything working as expected.

The unit and integration tests work so this would lead me to think that is something to do with Passenger.

Update It appears it has to do with the loaded defaults. Changing

config.load_defaults 7.0
# to =>
config.load_defaults 5.1

resolves the issue

Update 2

I have narrowed it down to this setting:

# Generate a `Link` header that gives a hint to modern browsers about
# preloading assets when using `javascript_include_tag` and `stylesheet_link_tag`.
# Rails.application.config.action_view.preload_links_header = true

This is in the new_framework_defaults_6_1.rb file. Uncommented or set to true, it errors very ambiguously. Set false, or commented, everything is good.

Romuloux
  • 1,027
  • 1
  • 8
  • 24

1 Answers1

0

Thanks a lot! It took me more than a day to find out what the problem was.

<%= render partial: 'scoreboard/score', collection: @owners, ...

If my collection grew over 33 objects the apache server sent a:

Premature end of script headers:...

This only happened in production with phusion_passenger but not on development with puma. So I changed the setting in environments/production.rb to

config.action_view.preload_links_header = false

Thanks a lot for the right hint!!!