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

Fixed bug preventing Amber from booting #497

Conversation

crimson-knight
Copy link
Member

  • Changed connection period to use less memory by switching to Int32 from Int64
  • Changed reader/writer to allow nil now that we have nil checks for when the connections are being used. This resolves the issue with Amber not being able to boot.

@crimson-knight
Copy link
Member Author

I tracked this down using the following steps:

If you care to test, you can go into your lib/granite/src/granite/connections.cr and use:
def self.first_connection
begin
first_connection = @@registered_connections.first?
raise "First registered connection cannot be nil" if first_connection.nil?
rescue ex
puts "Any registered connections? #{@@registered_connections.any?}"
ensure
first_connection = { name: "pg", url: "some-url" }
end
first_connection
end

Then in your config/database.cr

require "granite/adapter/pg"

puts "Loading connections..."
Granite::Connections << Granite::Adapter::Pg.new(name: "pg", url: ENV["DATABASE_URL"]? ||
Amber.settings.database_url)

puts "Done loading connections!
Then when the app boots, you'll see that the puts from the rescue statement fires twice because the config/database.cr file ever fires

After testing on a demo app this appears to have solved the issue.

@crimson-knight crimson-knight merged commit a996473 into amberframework:master Oct 26, 2023
13 checks passed
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.

1 participant