Closed pavloskafritsas closed 2 years ago
I tried reproducing the issue by creating a new laravel project. Everything works as expected. I even installed all the packages I am using and I couldn't reproduce the above issue.
Still, I cannot solve the issue on the project I'm working on. I tried:
1) Copying the new project config files (.env, app, auth, session, sanctum) to the old one
2) Copying \App\Http\Kernel
, \App\Http\Middleware\*
and AppServiceProvider
to the old one.
3) Deleting ./vendor folder
4) Deleting docker images & volumes ./vendor/bin/sail down --rmi all
5) Using php artisan serve
instead of sail
The issue still persists.
I also want to note that I used to have laravel breeze installed with the --api flag but now I removed it since I'm using GQL for the authentication purposes.
commands like php artisan route:list
and php artisan rote::cache
work. The cached result still misses the last character.
I could not reproduce it on a newly installed project. Also I updated two of my production projects to 9.16.0 yesterday, and both uses inertia.js -- which relies a lot on JSON response -- and I didn't find any problems.
Script I used:
#!/bin/bash
curl -s https://laravel.build/example-app | bash
cd example-app
echo "<?php Route::get('/test', fn () => [['now' => now()]]);" > ./routes/api.php
./vendor/bin/sail up
Testing:
$ curl http://localhost/api/test
[{"now":"2022-06-04T12:45:37.421602Z"}]
I see you are running on Linux, me too.
I am the original author of that stackoverflow post and this error occoured on fresh installation of version 9.15 for me. I temporarily solved this by adding dataType: 'text',
to ajax call and and then JSON.parse(response + ']');
in success
callback. But this is definitely a Laravel bug.
package.json
{ "private": true, "scripts": { "dev": "npm run development", "development": "mix", "watch": "mix watch", "watch-poll": "mix watch -- --watch-options-poll=1000", "hot": "mix watch --hot", "prod": "npm run production", "production": "mix --production" }, "devDependencies": { "@popperjs/core": "^2.10.2", "@tailwindcss/forms": "^0.4.0", "alpinejs": "^3.4.2", "autoprefixer": "^10.4.2", "axios": "^0.25", "bootstrap": "^5.1.3", "laravel-mix": "^6.0.6", "lodash": "^4.17.19", "postcss": "^8.4.6", "resolve-url-loader": "^5.0.0", "sass": "^1.32.11", "sass-loader": "^11.0.1", "tailwindcss": "^3.0.18" } }
Hey @Paulie-K
Can you please provide a reproducible outline on how to replicate the problem?
Otherwise it is very hard to help an issue without evidence, when there is evidence of the contrary.
Also, I don’t actually get why you shared your package.json as this file holds the frontend dependencies and you claim it is a Laravel (backend) issue.
I guess you wanted to share your composer.json file instead.
Otherwise if you are sure it is a JavaScript problem, I suggest you review your frontend code.
Oh thing I noticed, you mentioned this happened in version 9.15.0 for you.
Please update to the latest released version (9.16.0 at the time I am writing this) and check if you still gets the issue.
If the issue is still there, please provide a reproducible outline, or better yet, as suggested by the issue template, a public available repository created from a fresh project, with minimal code additions demonstrating the issue.
this happen even on 9.16 it happens even with "first party" web apps like Telescope: request from the "Requests" section will be truncated
@Ragash just tested with telescope in a fresh install using sail:
Installation steps:
#!/bin/bash
curl -s https://laravel.build/example-app | bash
cd example-app
echo "<?php Route::get('/test', fn () => [['now' => now()]]);" > ./routes/api.php
./vendor/bin/sail up
sail composer require laravel/telescope --dev
sail artisan telescope:install
sail artisan migrate
test the endpoint with:
$ curl http://localhost/api/test
[{"now":"2022-06-04T12:45:37.421602Z"}]
Edit TelescopeServiceProvider
and allow any user to access its panel, and then visit: http://localhost/telescope/requests
Request:
Response:
Please provide a public available repository with minimal changes showcasing the issue, as suggested by the issue template, otherwise it is very difficult to provide any help.
Can you please create a repository with the command below, commit the code that reproduces the issue as separate commits on the main/master branch and share the repository here? Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up.
laravel new bug-report --github="--public"
Please do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue.
I created the following repository to be used as a start point for reporters to instruct us on how to replicate the issue.
https://github.com/rodrigopedra/issue-42654
That repository:
Right now both Telescope dashboard and jQuery AJAX call work fine, and JSON responses are complete as expected.
Please add more commits to it with changes which demonstrate the issue. This will help us identify and try to fix the issue you are having. Please try to provide as many details you can to help us out on identifying this.
Thanks in advance!
Seems this is a Symfony issue. Please don't upgrade to Symfony v6.1 for now and wait until they release a patch release.
Description:
Today I updated my composer packages via the following command:
./vendor/bin/sail composer update
After updating the packages, all json type responses issued from the application's controllers are missing the last character, making the json response invalid.
After lots of searching I stumbled upon a stack overflow post describing the exact same issue:
https://stackoverflow.com/questions/72476635/laravel-json-response-is-missing-right-square-bracket-and-ajax-throws-parseerror
ATM, I have limited bandwidth so I didn't try to reproduce the bug on a fresh application. The following screenshot shows what my project looks like, the routes action and the response I get.
Laravel sets correctly the content-type header to application/json, yet the json is invalid. Logs are clear.