Amber 2.0.0-beta.12
Amber 2.0.0-beta.12 makes a default app smaller in memory and safer at the
door: it refuses compressed request bodies, stops keeping a session for every
visitor, and allocates less on every request.
What changed
- Compressed request bodies are refused (#1454). A request with a
compressed body is answered415 Unsupported Media Typebefore routing or
any pipe reads it. Crystal before 1.21.1 inflates gzip and deflate request
bodies with no size limit
(GHSA-jfq5-c3x6-w7jj),
so a 1 MiB body could become 1 GiB. The guard works on every compiler,
crystal-alpha 1.21.0 included. An app that accepts compressed uploads sets
params.accepts_encoded_request_bodies: trueand bounds the body itself. - Sessions follow
session.store(#1455). See the behavior change below.
Amber::Pipe::Flashwrites the session only when there is a flash to keep
or clear, so a visitor who never sees a flash gets no session. The memory
session adapter keeps at mostsession.max_memory_sessionssessions
(10,000 by default) and drops the one used longest ago. A:webroute
served to cookieless clients used to grow to 858 MiB in 90 s; it now stays
under 15 MiB. - The logger allocates nothing when its lines are filtered (#1456). At the
defaultinfolevelAmber::Pipe::Loggerused to build every debug line,
parse the params and create a session, about 11.8 KB per request, before
Logdropped it. Amber::Pipe::Compression(#1457). It gzips or deflates responses with
the same bytes asHTTP::CompressHandler, but its zlib streams come from
mallocand are reused through a small pool, whereHTTP::CompressHandler
allocates about 270 KB from the collected heap for every compressed
response. Amber CLI 2.0.12 apps use it throughCompressedResponsePipe.- Asset tags are rendered once per manifest (#1458).
stylesheet_link_tag,
javascript_include_tag,image_tag,favicon_tagand
javascript_importmap_tagreturn stored HTML on later calls. A generated
layout's three tags used to cost 6.9 KB per page.
Behavior change: signed_cookie sessions live in the cookie
store: signed_cookie is the default in every generated app. Through beta.11
every store, signed_cookie included, kept sessions in the server's memory.
From beta.12 a signed_cookie or encrypted_cookie app keeps the session in
the visitor's cookie and nothing on the server. Session values travel with
every request and must fit in a 4,096-byte cookie (a larger session raises
Amber::Exceptions::CookieOverflow), the visitor can read (but not change) a
signed_cookie session, and regenerate_session! does nothing. An app that
needs server-side sessions sets store: adapter under session:, or
AMBER_SESSION_STORE=adapter.
CHANGELOG.md has the complete list.
Upgrading
Use Amber CLI 2.0.12 for new apps. For an existing app, pin the release commit
in shard.yml, keep Grant v0.24.0 and asset_pipeline v0.38.0, run
minecart update amber, and run amber setup:agent. Check the session:
section of each config/environments/*.yml against the behavior change above.
To use the pooled compressor, make the generated CompressedResponsePipe a
subclass of Amber::Pipe::Compression with an empty body, or plug
Amber::Pipe::Compression.new in its place. New apps start the collector's
heap at 8 MiB (gc_initial_heap_mib: 8 under server:).
Pin this release
Commit: 834ef5d2790a1486b4c879e1b87ecd0c32e7809a
Tree: c07e799f09b91f002ca07e8f31c4dfc054e82fc4
Tarball: amber-2.0.0-beta.12.tar.gz (git archive --format=tar.gz --prefix=amber-2.0.0-beta.12/ 834ef5d2790a1486b4c879e1b87ecd0c32e7809a)
Tarball sha256: dff00f315038068013ac0cf5e0d1306cc5be1c3ebe0f185f7586651398345ca0
shard.lock checksum (Minecart 2025.11.25.9 and newer): sha256-v2:e54b07880db48f675951fc3d29221c97e3bed867d777972962d3b750ca6dfe5b
The tarball was built twice from the commit and gave the same sha256 both times.