Gert-dev / php-ide-serenata

Atom IDE package that integrates the Serenata server to provide PHP code assistance
https://serenata.gitlab.io/
Other
274 stars 19 forks source link

Serenata crash after upgrade to v5 #483

Closed marcguyer closed 4 years ago

marcguyer commented 5 years ago

I've enjoyed using Serenata in Atom for quite some time but since upgrade to v5, the server crashes almost immediately when indexing begins in my project. The console is littered with errors that don't seem to make much sense (to me anyway). Eventually this error pops up:

The PHP (Serenata) language server has exited and exceeded the restart limit for project '/Users/marcguyer/Documents/dev/chdr/cheddar/'

I've tried completely purging Serenata and related atom config from my system, then reinstalling the php-ide-serenata package in Atom but I get the same behavior.

I have a fairly large project where I'm seeing this behavior. I tried a smaller project and it doesn't seem to exhibit this issue. Unfortunately, I can't seem to find any indication of why one would crash the server while another doesn't. Here's an export of the console log from Atom:

serenata_console.log.zip

Gert-dev commented 5 years ago

Glad to hear you enjoyed it and sorry to hear that you're having problems now :smiley: .

Thanks for trying to help debug this by posting logs. I do see in the logs that the socket is being closed unexpectedly. It is possible that Serenata is indeed crashing.

If I understood correctly, Serenata is working for you correctly for the smaller project? If this is the case, then the problem for the larger project may be related to memory issues, though the default is already around 2GB, which is large (though I don't know how large your large is, of course). You can try upping it in the settings just to see if that is indeed the problem.

Apart from that, are you using Docker to run or just an ordinary PHP executable? I'm asking because Docker on macOS has its own, separate memory limit.

Finally, when this happens, could you take a look in the developer tools to see if under "All Levels" the "Verbose" setting is also enabled? There may be log messages from Serenata that are being hidden by default.

I also see this: PHP (Serenata) [Array(2)]0: (2) ["rpc.onError", Array(3)], could you take a look and see if there is anything of interest inside the Array(3) when this happens?

marcguyer commented 5 years ago

You can try upping it in the settings just to see if that is indeed the problem.

I doubled the mem to 4G with the same result. The project directory is ~1.5G but >1G of that is non-php dependencies -- mostly node_modules. The vendor dir is the bulk of the size and is ~300M.

Apart from that, are you using Docker to run or just an ordinary PHP executable?

The php executable on my mac:

$ php --version
PHP 7.1.23 (cli) (built: Feb 22 2019 22:19:32) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

... and for good measure:

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.14.6
BuildVersion:   18G95
$ atom --version
Atom    : 1.40.1
Electron: 3.1.10
Chrome  : 66.0.3359.181
Node    : 10.2.0

Finally, when this happens, could you take a look in the developer tools to see if under "All Levels" the "Verbose" setting is also enabled?

I enabled the verbose option. Here's the log with that enabled:

serenata_console.log.zip

I also see this: PHP (Serenata) [Array(2)]0: (2) ["rpc.onError", Array(3)], could you take a look and see if there is anything of interest inside the Array(3) when this happens?

image

Gert-dev commented 5 years ago

@lcharette gave me an idea. Could you try executing the following:

php ~/Library/Preferences/php-ide-serenata/distribution.phar --uri=127.0.0.1:12345

... and post the output? (I'm not entirely sure that is the right folder on macOS, so you may need to update it.)

It is possible I accidentally made the code incompatible with PHP < 7.3, e.g. by writing a trailing comma somewhere. Serenata has tests running on each PHP version individually, but there are some files, such as Main.php, that I don't think are touched by this.

Running Serenata manually should immediately trigger the error, if there is any, I hope.

marcguyer commented 5 years ago

No prob. It hangs here indefinitely:

$ php ~/Library/Preferences/php-ide-serenata/distribution.phar --uri=127.0.0.1:12345 -vvv
Starting server bound to socket on URI 127.0.0.1:12345...
Gert-dev commented 5 years ago

Hmm, that seems to be the expected behavior. So the server is not crashing immediately on startup, but the socket is immediately closing when it's started in Atom, though there is no strange output of any kind. In fact, I saw the same "Starting server..." message in your logs, the socket just closes sometime later.

Do you perhaps have some kind of firewall active that blocks arbitrary ports being opened?

marcguyer commented 5 years ago

Do you perhaps have some kind of firewall active that blocks arbitrary ports being opened?

No. Note that at least one other project I've tested in my env does not exhibit the behavior.

Gert-dev commented 5 years ago

Right, good of you to mention that, as I already forgot - dealing with too many tickets simultaneously, probably.

Do you have system logs of any kind that may have logged issues? It can always be e.g. a SIGSEGV that doesn't print any output.

If there are problems with the database or Serenata of any kind, you should always be seeing some sort of logging in Atom, so this is sounding more and more like an external factor or a severe issue (i.e. SIGSEGV) that is preventing output from being displayed.

marcguyer commented 5 years ago

This log seems to point to the problem since a similar entry coincides with each crash.

default 13:43:21.864078 -0400 kernel AMFI: disallowing exception handler for 'php' (pid: 42687, team: ''), because the handler was set by non-eligible process 'Atom' (76970) with Team ID 'VEKTX9H2N7' (not master-entitled).

Gert-dev commented 5 years ago

I did some lookup, but there doesn't appear to be a lot of information about AMFI. I did find that it supposedly refers to AppleMobileFileIntegrity and that this apparently also exists in macOS itself.

It may be coincidence in the sense that it is indeed disallowing the exception handler, but is only blocking it because the process crashed already, and not causing the crash itself.

Could you take a look if a database for the project that is crashing is generated in the php-ide-serenata cache folder (same one where the PHAR from before is located) and see if there are some items in the File table or some tables have data present?

In case you're feeling adventurous, Proxy.js contains the code that spawns the server. I took a look there again, but any output (STDOUT and STDERR) from the server should always be logged to the developer tools. If I add a LogicException, die, exit or anything to Serenata itself, or force an out of memory error from the PHP side, all of these show up.

There have been users in the past experiencing problems where some files in the php-ide-serenata cache folder were read-only.

You mentioned that Serenata crashes almost immediately "when indexing begins". This makes me wonder if there is something special along the lines of files (symlinks, files without read permissions, and so on), and so on, but I can't think of any of these that wouldn't generate some kind of error. For example, if Serenata cannot process a file due to it thinking that it contains syntax errors, a big fat error should show up in the developer tools.

EDIT: Another avenue is to clone latest Serenata git, run composer install and symlink the distribution.phar in the Serenata cache folder to the src/Main.php inside it. Then you can try opening up DirectoryIndexRequestDemuxer::index and try placing something along the lines of echo $fileInfo->getPathname() . PHP_EOL; inside the foreach loop. If the server is crashing on one of the files, some files should be showing up in the developer tools after you reload Atom.

marcguyer commented 5 years ago

I finally pinned this down and have a workaround in place in my env. I'm fairly certain you'll be able to replicate by installing fzaninotto/faker on a project and attempt to index it. The problem file was https://github.com/fzaninotto/Faker/blob/v1.8.0/src/Faker/Provider/nl_BE/Text.php ... which is nothing but a class with a single string property containing a large (~1M) nowdoc value. I suppose it could either be the size of this file or maybe a mangled character within it. My workaround is simply to delete that file from my project and reindex. Everything seems happy now. FYI, I also tried deleting most of content of the nowdoc value and that's a good workaround, too. Not sure if there was something in what I deleted that was the culprit or the size of it.

underdpt commented 5 years ago

I'm having the same problem, but your solution didn't help. I see this on the console:

Serenata unexpectedly closed. Either something caused the process to stop, it crashed, or the socket closed. In case of the first two, you should see additional output indicating this is the case and you can report a bug. If there is no additional output, you may be missing the right dependencies or extensions or the server may have run out of memory (you can increase it via the settings screen).
C:\Users\underdpt\.atom\packages\php-ide-serenata\lib\Proxy.js

And them the same error 8 or 10 times:

Uncaught (in promise) undefined
C:\Users\underdpt\.atom\packages\php-ide-serenata\node_modules\atom-languageclient\build\lib\server-manager.js:5

And finally:

Uncaught (in promise)
C:\Users\underdpt\.atom\packages\php-ide-serenata\lib\SerenataClient.js:253
Uncaught (in promise) undefined
C:\Users\underdpt\.atom\packages\php-ide-serenata\node_modules\atom-languageclient\build\lib\server-manager.js:5

There was also an error on ide-vue package, but I uninstalled that and it seems not related.

underdpt commented 5 years ago

FYI I've downgraded to 4.5.3 and it's working now (I had to set up more memory as I had a new crash due to the 2Gb limit).

Gert-dev commented 5 years ago

@marcguyer Good to hear you were able to pinpoint the issue.

I tried installing Faker in a test project, but the file seems to index just fine here. I even get code lenses in that file.

You are always welcome at the Serenata issue tracker if you have questions, have time and want to help track the issue down. It is possible that there is an indirect issue, perhaps indeed a character set issue (source code is converted to UTF-8 in Serenata before analysis), some PHP extension that has a specific setting causing problems with indexing, strange behavior of a native library during conversion of text, and so on.

@underdpt If you are also experiencing some projects that are working fine and others that aren't, you can try following the same process and answering the same questions as @marcguyer did above, perhaps there is also a specific file that is generating problems.

underdpt commented 5 years ago

HI @Gert-dev The issue happens with every project, some are Laravel-based, some are using composer and the older ones are php only, and fails with all projects. I even did setup serenata on some very old projects and saw the issue, so I'm pretty sure there's no a file causing the issue. Maybe isn't the same issue as @marcguyer 's one?

This happens in Windows OS, FYI. Anything I can do to debug this?

Gert-dev commented 4 years ago

@underdpt Are you using Xdebug? If so, it is possible you are a victim of #484.

underdpt commented 4 years ago

Yes, I'm using xdebug. Disabled Xdebug on the php version i'm using for Atom, updated to 5.0.2 and it's working, thanks! While waiting for the new version I'll setup a different php.ini for Atom/Serenata without xdebug.

Gert-dev commented 4 years ago

Thanks for letting me know. The issue should now be fixed (see also #484).

Gert-dev commented 4 years ago

I just realized the original issue with some files not being indexed likely wasn't fixed. This is however probably an issue in Serenata itself, so anyone is free to open an issue in Serenata's issue tracker for it (preferably with some sort of test case that I can reproduce as well :smile:).

ThomasLandauer commented 4 years ago

I'm getting the same error message as @marcguyer:

The PHP (Serenata) language server has exited and exceeded the restart limit for project ...

I tried

php ~/.cache/php-ide-serenata/distribution.phar --uri=127.0.0.1:12345

...and got:

Warning: pcntl_signal_dispatch() has been disabled for security reasons in phar:~/.cache/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/vendor/react/event-loop/src/StreamSelectLoop.php on line 232

So I removed pcntl_signal_dispatch from disable_functions in /etc/php/7.2/cli/php.ini.

Now, when reindexing the project in Atom, I'm getting this several thousand times in the console:

logger.ts:23 PHP (Serenata) [Array(1)]
error @ logger.ts:23
error @ logger.ts:82
error @ auto-languageclient.ts:403
handleResponse @ ~/.atom/packages/php-ide-serenata/node_modules/vscode-jsonrpc/lib/main.js:421
processMessageQueue @ ~/.atom/packages/php-ide-serenata/node_modules/vscode-jsonrpc/lib/main.js:263
setImmediate @ ~/.atom/packages/php-ide-serenata/node_modules/vscode-jsonrpc/lib/main.js:247
runCallback @ timers.js:789
tryOnImmediate @ timers.js:751
processImmediate @ timers.js:722

And the indexing runs endlessly...

marcguyer commented 4 years ago

I, too, have had a similar experience since the latest version last week. Prior to that update, everything was working well in my env. Previously my workaround was to remove a giant php file in an app dependency. I'm still not sure why Serenata chokes on that file...

The current problem appears to be different and should likely have it's own ticket -- Also, I don't know but I suspect the Serenata server rather than this Atom plugin as the source of the issue. Below is an example of the 1000's of entries I see in the Atom console. There seems to be an entry for each php file in my project.

Received response message without id: Error is: 
{
    "code": -32000,
    "message": "Could not index file due to an internal exception. This likely means an exception should be caught at a deeper level (if it is acceptable) or there is a bug. The file is \"file:///Users/marcguyer/Documents/dev/chdr/cheddar/test/FunctionalTest/SubscriptionPromotionDeleteTest/Fixture/InvoiceFixture.php\" and the exact exception message: \"Entity of type 'Serenata\\Indexing\\Structures\\File' for IDs id(5ddbf7d2047e06.25124117) was not found\"",
    "data": {
        "line": 136,
        "file": "phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Indexing/StorageFileIndexer.php",
        "backtrace": "→ Message 1
Could not index file due to an internal exception. This likely means an exception should be caught at a deeper level (if it is acceptable) or there is a bug. The file is \"file:///Users/marcguyer/Documents/dev/chdr/cheddar/test/FunctionalTest/SubscriptionPromotionDeleteTest/Fixture/InvoiceFixture.php\" and the exact exception message: \"Entity of type 'Serenata\\Indexing\\Structures\\File' for IDs id(5ddbf7d2047e06.25124117) was not found\"

→ Location 1
phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Indexing/StorageFileIndexer.php:136

→ Backtrace 1
#0 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Indexing/TextDocumentContentRegistryUpdatingIndexer.php(39): Serenata\\Indexing\\StorageFileIndexer->index(Object(Serenata\\Utility\\TextDocumentItem))
#1 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Indexing/UnmodifiedFileSkippingIndexer.php(51): Serenata\\Indexing\\TextDocumentContentRegistryUpdatingIndexer->index(Object(Serenata\\Utility\\TextDocumentItem))
#2 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Indexing/Indexer.php(164): Serenata\\Indexing\\UnmodifiedFileSkippingIndexer->index(Object(Serenata\\Utility\\TextDocumentItem))
#3 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Indexing/Indexer.php(110): Serenata\\Indexing\\Indexer->indexFile('file:///Users/m...', Array, Array, true)
#4 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/UserInterface/JsonRpcQueueItemHandler/IndexJsonRpcQueueItemHandler.php(59): Serenata\\Indexing\\Indexer->index('file:///Users/m...', true, Object(Serenata\\Sockets\\JsonRpcConnectionHandler))
#5 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/UserInterface/JsonRpcQueueItemHandler/IndexJsonRpcQueueItemHandler.php(48): Serenata\\UserInterface\\JsonRpcQueueItemHandler\\IndexJsonRpcQueueItemHandler->handle('file:///Users/m...', Object(Serenata\\Sockets\\JsonRpcConnectionHandler))
#6 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Sockets/JsonRpcQueueItemProcessor.php(135): Serenata\\UserInterface\\JsonRpcQueueItemHandler\\IndexJsonRpcQueueItemHandler->execute(Object(Serenata\\Sockets\\JsonRpcQueueItem))
#7 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Sockets/JsonRpcQueueItemProcessor.php(75): Serenata\\Sockets\\JsonRpcQueueItemProcessor->handle(Object(Serenata\\Sockets\\JsonRpcQueueItem))
#8 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/UserInterface/JsonRpcApplication.php(175): Serenata\\Sockets\\JsonRpcQueueItemProcessor->process(Object(Serenata\\Sockets\\JsonRpcQueueItem))
#9 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/UserInterface/JsonRpcApplication.php(139): Serenata\\UserInterface\\JsonRpcApplication->processNextQueueItem()
#10 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/vendor/react/event-loop/src/Timer/Timers.php(96): Serenata\\UserInterface\\JsonRpcApplication->Serenata\\UserInterface\\{closure}(Object(React\\EventLoop\\Timer\\Timer))
#11 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/vendor/react/event-loop/src/StreamSelectLoop.php(183): React\\EventLoop\\Timer\\Timers->tick()
#12 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/UserInterface/JsonRpcApplication.php(111): React\\EventLoop\\StreamSelectLoop->run()
#13 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/vendor/symfony/console/Command/Command.php(253): Serenata\\UserInterface\\JsonRpcApplication->runEventLoop(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#14 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/vendor/symfony/console/Application.php(1011): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#15 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/vendor/symfony/console/Application.php(272): Symfony\\Component\\Console\\Application->doRunCommand(Object(Symfony\\Component\\Console\\Command\\Command), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#16 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/vendor/symfony/console/Application.php(148): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#17 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/UserInterface/JsonRpcApplication.php(63): Symfony\\Component\\Console\\Application->run()
#18 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Main.php(24): Serenata\\UserInterface\\JsonRpcApplication->run()
#19 /Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar(10): include('phar:///Users/m...')
#20 {main}

→ Message 2
Entity of type 'Serenata\\Indexing\\Structures\\File' for IDs id(5ddbf7d2047e06.25124117) was not found

→ Location 2
phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/vendor/doctrine/orm/lib/Doctrine/ORM/EntityNotFoundException.php:47

→ Backtrace 2
#0 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/ProxyFactory.php(166): Doctrine\\ORM\\EntityNotFoundException::fromClassNameAndIdentifier('Serenata\\\\Indexi...', Array)
#1 /private/var/folders/1z/fjvy463n0lgdm8q4jvm0pfph0000gn/T/__CG__SerenataIndexingStructuresFile.php(219): Doctrine\\ORM\\Proxy\\ProxyFactory->Doctrine\\ORM\\Proxy\\{closure}(Object(DoctrineProxies\\__CG__\\Serenata\\Indexing\\Structures\\File), 'getUri', Array)
#2 /private/var/folders/1z/fjvy463n0lgdm8q4jvm0pfph0000gn/T/__CG__SerenataIndexingStructuresFile.php(219): Closure->__invoke(Object(DoctrineProxies\\__CG__\\Serenata\\Indexing\\Structures\\File), 'getUri', Array)
#3 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Analysis/Conversion/NamespaceConverter.php(22): DoctrineProxies\\__CG__\\Serenata\\Indexing\\Structures\\File->getUri()
#4 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Analysis/DoctrineNamespaceListProvider.php(79): Serenata\\Analysis\\Conversion\
amespaceConverter->convert(Object(Serenata\\Indexing\\Structures\\FileNamespace))
#5 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Analysis/DoctrineNamespaceListProvider.php(50): Serenata\\Analysis\\DoctrineNamespaceListProvider->mapNamespaces(Array)
#6 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Analysis/NamespaceListRegistry.php(91): Serenata\\Analysis\\DoctrineNamespaceListProvider->getAll()
#7 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Analysis/NamespaceListRegistry.php(82): Serenata\\Analysis\
amespaceListRegistry->initializeRegistry()
#8 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Analysis/NamespaceListRegistry.php(41): Serenata\\Analysis\
amespaceListRegistry->initializeRegistryIfNecessary()
#9 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Mediating/NamespaceIndexingNamespaceRegistryMediator.php(57): Serenata\\Analysis\
amespaceListRegistry->add(Array)
#10 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(123): Serenata\\Mediating\
amespaceIndexingNamespaceRegistryMediator->Serenata\\Mediating\\{closure}(Object(Serenata\\Indexing\\Structures\\FileNamespace))
#11 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Indexing/EventEmittingStorage.php(153): Serenata\\Indexing\\EventEmittingStorage->emit('namespaceUpdate...', Array)
#12 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Indexing/EventEmittingStorage.php(123): Serenata\\Indexing\\EventEmittingStorage->dispatchScheduledEvents()
#13 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Indexing/StorageFileIndexer.php(194): Serenata\\Indexing\\EventEmittingStorage->commitTransaction()
#14 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Indexing/StorageFileIndexer.php(125): Serenata\\Indexing\\StorageFileIndexer->indexNamespacesWithUseStatements(Array, Object(Serenata\\Indexing\\Structures\\File), Object(Serenata\\Utility\\TextDocumentItem))
#15 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Indexing/TextDocumentContentRegistryUpdatingIndexer.php(39): Serenata\\Indexing\\StorageFileIndexer->index(Object(Serenata\\Utility\\TextDocumentItem))
#16 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Indexing/UnmodifiedFileSkippingIndexer.php(51): Serenata\\Indexing\\TextDocumentContentRegistryUpdatingIndexer->index(Object(Serenata\\Utility\\TextDocumentItem))
#17 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Indexing/Indexer.php(164): Serenata\\Indexing\\UnmodifiedFileSkippingIndexer->index(Object(Serenata\\Utility\\TextDocumentItem))
#18 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Indexing/Indexer.php(110): Serenata\\Indexing\\Indexer->indexFile('file:///Users/m...', Array, Array, true)
#19 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/UserInterface/JsonRpcQueueItemHandler/IndexJsonRpcQueueItemHandler.php(59): Serenata\\Indexing\\Indexer->index('file:///Users/m...', true, Object(Serenata\\Sockets\\JsonRpcConnectionHandler))
#20 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/UserInterface/JsonRpcQueueItemHandler/IndexJsonRpcQueueItemHandler.php(48): Serenata\\UserInterface\\JsonRpcQueueItemHandler\\IndexJsonRpcQueueItemHandler->handle('file:///Users/m...', Object(Serenata\\Sockets\\JsonRpcConnectionHandler))
#21 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Sockets/JsonRpcQueueItemProcessor.php(135): Serenata\\UserInterface\\JsonRpcQueueItemHandler\\IndexJsonRpcQueueItemHandler->execute(Object(Serenata\\Sockets\\JsonRpcQueueItem))
#22 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Sockets/JsonRpcQueueItemProcessor.php(75): Serenata\\Sockets\\JsonRpcQueueItemProcessor->handle(Object(Serenata\\Sockets\\JsonRpcQueueItem))
#23 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/UserInterface/JsonRpcApplication.php(175): Serenata\\Sockets\\JsonRpcQueueItemProcessor->process(Object(Serenata\\Sockets\\JsonRpcQueueItem))
#24 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/UserInterface/JsonRpcApplication.php(139): Serenata\\UserInterface\\JsonRpcApplication->processNextQueueItem()
#25 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/vendor/react/event-loop/src/Timer/Timers.php(96): Serenata\\UserInterface\\JsonRpcApplication->Serenata\\UserInterface\\{closure}(Object(React\\EventLoop\\Timer\\Timer))
#26 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/vendor/react/event-loop/src/StreamSelectLoop.php(183): React\\EventLoop\\Timer\\Timers->tick()
#27 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/UserInterface/JsonRpcApplication.php(111): React\\EventLoop\\StreamSelectLoop->run()
#28 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/vendor/symfony/console/Command/Command.php(253): Serenata\\UserInterface\\JsonRpcApplication->runEventLoop(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#29 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/vendor/symfony/console/Application.php(1011): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#30 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/vendor/symfony/console/Application.php(272): Symfony\\Component\\Console\\Application->doRunCommand(Object(Symfony\\Component\\Console\\Command\\Command), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#31 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/vendor/symfony/console/Application.php(148): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#32 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/UserInterface/JsonRpcApplication.php(63): Symfony\\Component\\Console\\Application->run()
#33 phar:///Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar/builds/Serenata/Serenata/src/Main.php(24): Serenata\\UserInterface\\JsonRpcApplication->run()
#34 /Users/marcguyer/Library/Preferences/php-ide-serenata/distribution.phar(10): include('phar:///Users/m...')
#35 {main}"
    }
}

I suppose it could be that I have a "corrupted" index at this point so I'll reset everything again and see what I get in the console.

marcguyer commented 4 years ago

I tried this again on 2 different projects after resetting everything (delete phar and index dbs, ensure no zombie php processes, restart Atom). Both projects indexed completely. Aside, it appears that the primary difference in the latest minor version of the server (5.1.0) is that the phar itself is indexed and included into the same index as the project. @gert-dev wouldn't it be more efficient to have a dedicated index for the phar? Just asking... I suppose there are likely some technological limitations there...

Both projects are happy right now but I've fallen for that ruse before... Based on recent experience, I expect to start seeing errors in the console after coding for a bit. I'll keep an eye on it and report back here either way.

marcguyer commented 4 years ago

So far, no errors after reinitializing... I think both the error I reported last and what @ThomasLandauer is experiencing is reported in the the server here: https://gitlab.com/Serenata/Serenata/issues/307. However, contrary to that issue report description, it's not just annoying messages, but also that the server eventually fails due to repeated crashes.

ThomasLandauer commented 4 years ago

Thanks to @marcguyer the following steps fixed it for me (at least for the moment):

  1. Remove pcntl_signal_dispatch from disable_functions in /etc/php/7.2/cli/php.ini. This was probably the real "fix".
  2. Delete .serenata folder in my project.
  3. Delete the .sqlite file mentioned in .serenata/config (in my case: ~/.cache/php-ide-serenata/index-9ad86880cad3838e6f04b520419e6ee4.sqlite)
  4. Delete the .sqlite-shm and .sqlite-wal file from there too
  5. In Atom: Packages > Serenata > Set Up Current Project, then > (Re)Index Project

Result: Indexing ran through just fine :-)

Gert-dev commented 4 years ago

Thanks for letting me know.

I've added some documentation to the wiki about possible extensions you can use for the Event Loop. There wasn't any documentation about this previously, so it was hard for anyone to know the server is even using it.

For the SQLite database, users have been reporting corruptions as long as I can remember (I haven't experienced them myself, though). Possibly it is related to varying combinations of hardware and software, which are rather hard to debug. In SqliteConnectionFactory in the server I disable synchronous for the database, which can cause corruption, but I would expect that to only happen on severe crashes. Still, you could try tinkering with the settings.

Finally, you are right, this package doesn't do any indexing itself, most issues, barring cosmetic ones and ones related to integration, are happening in the server or Serenata itself.

marcguyer commented 4 years ago

To be clear, I'm using "corruption" as a generic term. Whenever I run into these issues, I brute-force reset everything to a known state to avoid my unknowns and get a clean run from scratch. I'm not sure I can say that true db corruption has ever been experienced. I've only suspected that the db is in an unexpected state at times... Specifically, when I see hundreds of "Could not find file xxx in index" I must assume that the file is expected to be in the index. I understand that IRL you could have a situation where a file is expected to not exist in the index -- copy/paste, etc -- but these are all files that I expect were already previously indexed, making the error a surprise.

lsalomon commented 4 years ago

Hi everyone !

Great work indeed with serenata ! I'm loving it daily !

I just wan't to describe what I figured out, experiencing the same issues with infinite loop of exceptions leading to serenata crashes and not finding files into the index.

I thought maybe that my project / my IDE were in an conflicting state so I investigated. I saw that my serenata was up to date, but not my atom. So I erased my .serenata folder, upgrade and restart my atom. It was still not working. Then I uninstall my serenata package, reload my window, reinstall serenata... It works like a charm now. Not a single exception right now.

Hope it will help,

Cheers