spotlight icon indicating copy to clipboard operation
spotlight copied to clipboard

Duplicate in production ( Laravel Vapor )

Open cloudstudio opened this issue 2 years ago • 5 comments

Hello guys! something weird is happening.

Working super super nice in local as allways, when we deploy in production, using laravel vapor + serverless this is what I see:

Captura de pantalla 2022-12-19 a las 11 14 01

As you see is duplicated 3 times, this happend with all commands.

I try creating custom custom provider, or just using default livewire-ui-spotlight.php

Any ideas?

`<?php

return [

/*
|--------------------------------------------------------------------------
| Shortcuts
|--------------------------------------------------------------------------
|
| Define which shortcuts will activate Spotlight CTRL / CMD + key
| The default is CTRL/CMD + K or CTRL/CMD + /
|
 */

'shortcuts' => [
    'k',
    'slash',
],

/*
|--------------------------------------------------------------------------
| Commands
|--------------------------------------------------------------------------
|
| Define which commands you want to make available in Spotlight.
| Alternatively, you can also register commands in your AppServiceProvider
| with the Spotlight::registerCommand(Logout::class); method.
|
 */

'commands' => [
    App\Spotlight\SearchVehicle::class
],

/*
|--------------------------------------------------------------------------
| Include CSS
|--------------------------------------------------------------------------
|
| Spotlight uses TailwindCSS, if you don't use TailwindCSS you will need
| to set this parameter to true. This includes the modern-normalize css.
|
 */
'include_css' => false,

/*
|--------------------------------------------------------------------------
| Include JS
|--------------------------------------------------------------------------
|
| Spotlight will inject the required Javascript in your blade template.
| If you want to bundle the required Javascript you can set this to false,
| call 'npm install fuse.js' or 'yarn add fuse.js',
| then add `require('vendor/livewire-ui/spotlight/resources/js/spotlight');`
| to your script bundler like webpack.
|
 */
'include_js' => true,

]; `

cloudstudio avatar Dec 19 '22 10:12 cloudstudio

Any chance you are using Laravel Octane?

PhiloNL avatar Dec 19 '22 19:12 PhiloNL

Hello @PhiloNL yes! using Laravel Octane, is because of this ?

cloudstudio avatar Dec 20 '22 07:12 cloudstudio

Yes, the following is creating a memory leak: https://github.com/wire-elements/spotlight/blob/master/src/Spotlight.php#L20

I think changing it to the following will fix it:

    public static function registerCommand(string $command): void
    {
        tap(new $command, function (SpotlightCommand $command) {
            self::$commands[$command->getId()] = $command;
        });
    }

I'll see if I can test this later this week.

PhiloNL avatar Dec 20 '22 17:12 PhiloNL

Let me know if I can help testing it, thanks !

cloudstudio avatar Dec 23 '22 08:12 cloudstudio

Any update?

Krato avatar Feb 24 '23 12:02 Krato