[ 
https://issues.apache.org/jira/browse/ARTEMIS-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18007615#comment-18007615
 ] 

Grzegorz Grzybek commented on ARTEMIS-5546:
-------------------------------------------

OK, the third time is the charm....

The bug is in...
{code:javascript}
    constructor() {
        this.brokerObjectName = this.initBrokerObjectName();
        this.brokerInfo = this.initBrokerInfo();
    }
{code}

{{@hawtio/react}} 1.10.x will have some improvements related to configuration 
fetching.

The problem with uncaught promise is that it was caught only with webpack dev 
server which provides handler for 
[unhandlerrejection|https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event]
 event.

And here's clear explanation - constructors of JavaScript classes are invoked 
in kind of "static way" during JavaScript {{import}} statement. This statement 
is of course translated to Webpack code (because the bundle doesn't contain any 
real JavaScript import or import() statements/operators).

Here this is the contructor of {{ArtemisService}} class which is exported with:
{code:javascript}
export const artemisService = new ArtemisService()
{code}

there's no real try..catch around this global export and {{initBrokerInfo}} 
promise is simply rejected, because when connecting to external broker, we are 
not logged in yet.

I have two fixes. The first one simply prevents calling {{reject()}} and simply 
resolves the promises initialized in the constructor with {{null}} value - 
Hawtio/Console will be reloaded anyway after logging in to Artemis.

The second fix will be larger and I'll add it as part of bigger refactoring, 
where initialization code and code that fetches some JSONs will be handled in 
better places than JavaScript constructor.

In {{@hawtio/react}} 1.10.x we have similar refactoring (roughly: _no fetch in 
constructors_) and it allowed us do do better logging screens, better handling 
of OIDC/Keycloak login (on demand), etc.


> webpack-dev-server 5.x issue with uncaught promise
> --------------------------------------------------
>
>                 Key: ARTEMIS-5546
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-5546
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: Web Console
>            Reporter: Grzegorz Grzybek
>            Priority: Major
>
> With https://github.com/apache/activemq-artemis-console/pull/103 we now have 
> issues when using {{webpack-dev-server}} when running the application from 
> {{artemis-console-extension/artemis-extension/app}}.
> I'll try to track down the uncaught promise.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to