Closed atrandafir closed 1 month ago
If it happens only once a day it can be related to underlying bolt protocol library, it process collected analytics once a day. I don't see any echo or anything else what would cause it, but you can opt out from analytics with setting environment variable BOLT_ANALYTICS_OPTOUT to any value.
Thanks @stefanak-michal that was on my mind cause I have been inspecting the code, I'll try it out.
By the way, in the first deployment on the live server, I had some issues because for some reason php's default temp directory wasn't writable by the web server and I had to run this in order to temporarily fix it:
mkdir vendor/stefanak-michal/bolt/temp
chmod -R 777 vendor/stefanak-michal/bolt/temp
sudo chown -R bitnami:daemon vendor/stefanak-michal/bolt/temp/
Again I haven't tried to deploy it on a different server to see if this is common, but if anybody has that permission issue on the temp directorly they might run into this problem.
Hi again, effectively I have been able to reproduce the bug on demand:
Basically I modified Bolt library code to always run the track method no matter what:
And I got the bug:
And yes this solves it for now:
putenv("BOLT_ANALYTICS_OPTOUT=1");
Also can't really figure out by a short look at the track() method code what actually causes to print the 1 on the screen.
@atrandafir that is unfortunate you cannot tell what is causing it in your environment. Could be possible to share your php.ini with me?
Hi again @stefanak-michal yes it is solved on my environment by using the ENV opt out.
But I did found what solves the bug in the code, basically changing this from false to true on the cURL call:
CURLOPT_RETURNTRANSFER => true,
Apparently if we tell cURL to not return the transfer, it will print the result of curl_exec
on the screen (true/false), and it is that true that gets printed as "1".
https://stackoverflow.com/questions/4803948/curl-exec-printing-results-when-i-dont-want-to
Then the results of the request will be returned but nothing gets done with it since it is not assigned to a variable, but the bug goes away at least.
So in other words, you could return the transfer, decode it and check if the actual analytics request was okay before deleting the file.
Anyways, that change fixes it.
Good to know, thanks for doing some reserach and feedback, I'll look into it when I'll be at computer
Issue was solved, therefore it can be closed.
Amazing
Describe the bug
I have these Ajax requests that take data out of Neo4j in order to paint some charts and tables.
On the first daily run of my PHP web application, the ajax response is corrupted by the digit "1" appearing before the encoded JSON.
Example:
I refresh my screen and run all these AJAX requests again, and the bug goes away (the "1" in front of the json content disappears).
It only happens every day on the first run and this is why I consider this bug very weird.
I'm posting it here because I think it is either related to something going on with Neo4j library and dependencies or with the process of encoding/decoding the data. It might not be 100% related to Neo4j but then again, it ONLY happens on the AJAX requests that DO interact with Neo4j.
To Reproduce
I have built a Neo4j client by using the example app here: https://github.com/neo4j-examples/movies-php-client
The connection string goes like this:
neo4j://
123.123.123.123?database=neo4j`Then I run a query on Neo4j and output the results:
Expected behavior
I should get a clean ajax response starting with
{
and ending in}
.Instead the ajax response starts with
1{
as if some part of the code printed the number 1 before the output.Weird thing is it ONLY happens ONCE. Reload the page and it works well until the first run on next day.
Screenshots
Desktop (please complete the following information):
Neo4j Version:
5.20.0 Community
PHP version:
Additional context
Link to live server: https://tools.futurity.science/snapshot/metaverse
But again. The bug happens randomly and you'll only see it if you're the first visitor in that day.
I know it sounds weird but the only thing I can think of is that something like this happens somewhere internally:
Only thing I will try is to update the way I'm connecting to Neo4j since I'm using code from the Movies example and I see it is not the same code as the documentation on this repo.