humhub / fcm-push

Enables your users to receive push notifications from your network.
5 stars 7 forks source link

Cache Clear Error: Missing `firebase-messaging-compat.js.map` #59

Closed ArchBlood closed 2 weeks ago

ArchBlood commented 3 weeks ago

The following error can pop up when clearing cache, it doesn't happen all the time but does happen

Error log

yii\base\ErrorException: copy(/home/USER/SITE/assets/196ca446/firebase-messaging-compat.js.map): Failed to open stream: No such file or directory in /home/USER/SITE/protected/vendor/yiisoft/yii2/helpers/BaseFileHelper.php:411
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleError()
#1 /home/USER/SITE/protected/vendor/yiisoft/yii2/helpers/BaseFileHelper.php(411): copy()
#2 /home/USER/SITE/protected/vendor/yiisoft/yii2/web/AssetManager.php(591): yii\helpers\BaseFileHelper::copyDirectory()
#3 /home/USER/SITE/protected/vendor/yiisoft/yii2/web/AssetManager.php(487): yii\web\AssetManager->publishDirectory()
#4 /home/USER/SITE/protected/vendor/yiisoft/yii2/web/AssetBundle.php(181): yii\web\AssetManager->publish()
#5 /home/USER/SITE/protected/vendor/yiisoft/yii2/web/AssetManager.php(294): yii\web\AssetBundle->publish()
#6 /home/USER/SITE/protected/humhub/components/AssetManager.php(66): yii\web\AssetManager->loadBundle()
#7 /home/USER/SITE/protected/vendor/yiisoft/yii2/web/AssetManager.php(265): humhub\components\AssetManager->loadBundle()
#8 /home/USER/SITE/protected/vendor/yiisoft/yii2/web/View.php(301): yii\web\AssetManager->getBundle()
#9 /home/USER/SITE/protected/humhub/modules/ui/view/components/View.php(255): yii\web\View->registerAssetBundle()
#10 /home/USER/SITE/protected/vendor/yiisoft/yii2/web/AssetBundle.php(125): humhub\modules\ui\view\components\View->registerAssetBundle()
#11 /home/USER/SITE/protected/modules/fcm-push/Events.php(115): yii\web\AssetBundle::register()
#12 [internal function]: humhub\modules\fcmPush\Events::onLayoutAddonInit()
#13 /home/USER/SITE/protected/vendor/yiisoft/yii2/base/Event.php(312): call_user_func()
#14 /home/USER/SITE/protected/vendor/yiisoft/yii2/base/Component.php(654): yii\base\Event::trigger()
#15 /home/USER/SITE/protected/vendor/yiisoft/yii2/base/Widget.php(76): yii\base\Component->trigger()
#16 /home/USER/SITE/protected/humhub/widgets/BaseStack.php(71): yii\base\Widget->init()
#17 /home/USER/SITE/protected/humhub/widgets/LayoutAddons.php(47): humhub\widgets\BaseStack->init()
#18 /home/USER/SITE/protected/vendor/yiisoft/yii2/base/BaseObject.php(109): humhub\widgets\LayoutAddons->init()
#19 [internal function]: yii\base\BaseObject->__construct()
#20 /home/USER/SITE/protected/vendor/yiisoft/yii2/di/Container.php(411): ReflectionClass->newInstanceArgs()
#21 /home/USER/SITE/protected/vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build()
#22 /home/USER/SITE/protected/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get()
#23 /home/USER/SITE/protected/humhub/components/Widget.php(59): yii\BaseYii::createObject()
#24 /home/USER/SITE/protected/humhub/modules/ui/view/components/View.php(498): humhub\components\Widget::widget()
#25 /home/USER/SITE/protected/humhub/views/layouts/main.php(69): humhub\modules\ui\view\components\View->endBody()
#26 /home/USER/SITE/protected/vendor/yiisoft/yii2/base/View.php(348): require('/home/USER/...')
#27 /home/USER/SITE/protected/vendor/yiisoft/yii2/base/View.php(258): yii\base\View->renderPhpFile()
#28 /home/USER/SITE/protected/humhub/components/Controller.php(155): yii\base\View->renderFile()
#29 /home/USER/SITE/protected/vendor/yiisoft/yii2/base/Controller.php(408): humhub\components\Controller->renderContent()
#30 /home/USER/SITE/protected/humhub/modules/admin/controllers/SettingController.php(139): yii\base\Controller->render()
#31 [internal function]: humhub\modules\admin\controllers\SettingController->actionCaching()
#32 /home/USER/SITE/protected/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#33 /home/USER/SITE/protected/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#34 /home/USER/SITE/protected/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction()
#35 /home/USER/SITE/protected/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction()
#36 /home/USER/SITE/protected/vendor/yiisoft/yii2/base/Application.php(384): yii\web\Application->handleRequest()
#37 /home/USER/SITE/index.php(28): yii\base\Application->run()
#38 {main}

Suggestion

Update the FirebaseAsset class as follows which seems to help fix the issue;

<?php

/**
 * @link https://www.humhub.org/
 * @copyright Copyright (c) 2015 HumHub GmbH & Co. KG
 * @license https://www.humhub.com/licences
 */

namespace humhub\modules\fcmPush\assets;

use humhub\components\assets\AssetBundle;

class FirebaseAsset extends AssetBundle
{
    /**
     * @inheritdoc
     */
    public $defer = false;

    /**
     * @inheritdoc
     */
    public $sourcePath = '@fcm-push/vendor/npm-asset/firebase';

    /**
     * @inheritdoc
     */
    public $js = [
        'firebase-app-compat.js',
        'firebase-messaging-compat.js',
    ];

    /**
     * Exclude source map files from being published.
     * @inheritdoc
     */
    public $publishOptions = [
        'only' => [
            'firebase-app-compat.js',
            'firebase-messaging-compat.js',
        ]
    ];
}
luke- commented 3 weeks ago

@ArchBlood What did you modify in the class?

ArchBlood commented 3 weeks ago

Added the following, no other modifications have been made to the core of v1.17 or the latest version of the module.

    /**
     * Exclude source map files from being published.
     * @inheritdoc
     */
    public $publishOptions = [
        'only' => [
            'firebase-app-compat.js',
            'firebase-messaging-compat.js',
        ]
    ];
luke- commented 3 weeks ago

Hmm, can you reproduce the issue on our community (latest develop) version?

ArchBlood commented 3 weeks ago

Hmm, can you reproduce the issue on our community (latest develop) version?

Currently with the community site the following console errors happen as for this specific error, I have no access to clear cache via File from the community site so I would not know if it can be reproduced on the community site.

Unchecked runtime.lastError: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received

dashboard:1 Unchecked runtime.lastError: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received

dashboard:1 Unchecked runtime.lastError: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received

dashboard:1 Unchecked runtime.lastError: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received
luke- commented 3 weeks ago

Do you think the error only occurs with the “file” cache backend?

Can you send a screenshot of the console errors? Do they occur on a specific page?

ArchBlood commented 3 weeks ago

Do you think the error only occurs with the “file” cache backend?

Can you send a screenshot of the console errors? Do they occur on a specific page?

After updating my current test site for #44 I have no errors that are noticeable, I'll have to create a new instance once I'm back at the office, which will probably be around Tuesday due to Monday being Veteran's Day here. I've only tested with File and no other option due to Cron issues with APCu flushing cache when disabling or deleting modules.

ArchBlood commented 3 weeks ago

Currently the following errors show when accessing the mail module but that can be left for a separate issue, currently I haven't seen the issues reported in https://github.com/humhub/fcm-push/issues/59#issuecomment-2466295289 again since yesterday.

Screenshot_1

luke- commented 2 weeks ago

Thanks for the feedback. For the errors in the console, we probably need issues in the core. But I think there was already a PR about this. I'm closing the issue here. If it occurs again, please reopen it. Thanks!