I have a problem with my app It is deployed with symfony 6.3.2 on the backend I think it's on an nginx server with docker The library used for the api is api-platform
Whenever I make some calls to API like BASE_URL/api/currencies 1-2 times out of 10 I have an error This is part of the trace
{
{
"@context": "\/api\/contexts\/Error",
"@type": "hydra:Error",
"hydra:title": "An error occurred",
"hydra:description": "unlink(): Argument #1 ($filename) must not contain any null bytes",
"trace": [
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "",
"file": "\/app\/vendor\/symfony\/http-kernel\/Profiler\/FileProfilerStorage.php",
"line": 332,
"args": []
},
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "unlink",
"file": "\/app\/vendor\/symfony\/http-kernel\/Profiler\/FileProfilerStorage.php",
"line": 332,
"args": []
},
{
"namespace": "Symfony\\Component\\HttpKernel\\Profiler",
"short_class": "FileProfilerStorage",
"class": "Symfony\\Component\\HttpKernel\\Profiler\\FileProfilerStorage",
"type": "->",
"function": "removeExpiredProfiles",
"file": "\/app\/vendor\/symfony\/http-kernel\/Profiler\/FileProfilerStorage.php",
"line": 182,
"args": []
}
So the error is from the unlink() function which is used to delete files From what I read from New in symfony 6.3 (improvements) , they introduced a feature to automatically delete profiles after some time. In practice, on each request there's a 10% random chance that Symfony activates the deletion feature. When it's activated, any profile created two days ago or earlier is deleted. Which surely explains why sometimes my requests fail and sometimes they work it is surely trying to remove expired profiles with removeExpiredProfiles() function What is strange is that even when the request fails I get the data at the beginning
This is an example of when it works
{
"@context": "\/api\/contexts\/Currency",
"@id": "\/api\/currencies\/1",
"@type": "Currency",
"id": 1,
"uuid": "018ec2aa-3105-71a3-bc59-bd5e81b146ef",
"code": "EUR",
"name": "Euros"
}
And this is an example of when it fails
{
"@context": "\/api\/contexts\/Currency",
"@id": "\/api\/currencies\/1",
"@type": "Currency",
"id": 1,
"uuid": "018ec2aa-3105-71a3-bc59-bd5e81b146ef",
"code": "EUR",
"name": "Euros"
}{
"@context": "\/api\/contexts\/Error",
"@type": "hydra:Error",
"hydra:title": "An error occurred",
"hydra:description": "unlink(): Argument #1 ($filename) must not contain any null bytes",
"trace": [
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "",
"file": "\/app\/vendor\/symfony\/http-kernel\/Profiler\/FileProfilerStorage.php",
"line": 332,
"args": []
},
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "unlink",
"file": "\/app\/vendor\/symfony\/http-kernel\/Profiler\/FileProfilerStorage.php",
"line": 332,
"args": []
},
{
"namespace": "Symfony\\Component\\HttpKernel\\Profiler",
"short_class": "FileProfilerStorage",
"class": "Symfony\\Component\\HttpKernel\\Profiler\\FileProfilerStorage",
"type": "->",
"function": "removeExpiredProfiles",
"file": "\/app\/vendor\/symfony\/http-kernel\/Profiler\/FileProfilerStorage.php",
"line": 182,
"args": []
},
...
Any help would greatly be appreciated Thanks
What I tried to do is to clone the backend locally in dev mode with the exact versions of php, symfony, and all packages installed by composer as the ones in prod I exepcted to have the same error in dev and conclude that some libraries were not up to date But in dev I never have that error I don't understand why
The error indicates that the issue lies with the profiler. In production, it should normally be disabled.
Which composer command did you use in production to install your packages?
What is the value of your APP_ENV in your .env file?