Skip to content

Delete the files uploaded with each request - #219

Merged
mnapoli merged 2 commits into
masterfrom
octane-cleanup-uploaded-files
Oct 12, 2026
Merged

mnapoli merged 2 commits into
masterfrom
octane-cleanup-uploaded-files

Conversation

@mnapoli

@mnapoli mnapoli commented Oct 12, 2026

Copy link
Copy Markdown
Member

Takes over #218 by @felipehertzer, whose commit is kept as is.

Files uploaded to a Laravel application running with Octane were never deleted: they stayed in the Lambda instance's /tmp until it was full, and then everything that writes to /tmp failed (including Laravel's storage, which is in /tmp on Lambda).

#218 calls Bref's Psr7Bridge::cleanupUploadedFiles() when a request starts, like Bref's Psr15Handler does. That was not enough on its own:

  • Symfony's HttpFoundationFactory moves every file Bref uploads to a new temporary file named symfony* (the file is not a native PHP upload), so the cleanup, which deletes bref_upload_* files, never found it. SymfonyRequestBridge now names those files with Bref's prefix.
  • Since PHP 8.4, tempnam() adds 19 random characters instead of 6, and Bref's cleanup only matched 6: fixed in Bref 3.0.13 (Delete uploaded files on PHP 8.4 and up bref#2218), which is now required.
  • Bref\LaravelBridge\Http\HttpHandler, the handler without Octane, goes through the same bridge and did not call the cleanup either.

The SymfonyRequestBridge test fails without the renaming, and the handler tests fail without the cleanup call. They pass on macOS and on Linux with PHP 8.4.

felipehertzer and others added 2 commits October 12, 2026 18:35
the Psr15Handler already do it with Psr7Bridge::cleanupUploadedFiles() but
the OctaneHandler never call it, so the uploads stay in /tmp until the lambda
instance is recycled
Symfony's HttpFoundationFactory moves every file Bref uploads to a new
temporary file named "symfony*", so Psr7Bridge::cleanupUploadedFiles(),
which deletes "bref_upload_*" files, never found them. The non-Octane
HttpHandler did not call the cleanup either.

Bref 3.0.13 is required: before it, the cleanup missed every upload on
PHP 8.4 and up.
@mnapoli

mnapoli commented Oct 12, 2026

Copy link
Copy Markdown
Member Author

Tested in prod

@mnapoli
mnapoli merged commit d47f115 into master Oct 12, 2026
6 checks passed
@mnapoli
mnapoli deleted the octane-cleanup-uploaded-files branch October 12, 2026 13:24
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