[OutSystems Maps] Cannot read properties of undefined (reading: dispose)
outsystems-maps
Reactive icon
Forge component by Platform Maintenance
Application Type
Reactive

Sometimes the Maps component is destroyed before it completed initialization, throwing an unhandled javascript exception:


TypeError: Cannot read properties of undefined (reading 'dispose')

    at Map.dispose (https://mysite.com/Job/scripts/OutSystemsMaps.OutSystemsMaps.js?BAGpbsEzTulfFjBgJ28Zkg:2899:32)

    at Object.RemoveMap (https://mysite.com/Job/scripts/OutSystemsMaps.OutSystemsMaps.js?BAGpbsEzTulfFjBgJ28Zkg:7044:17)

    at https://mysite.com/Job/scripts/OutSystemsMaps.controller.js?wh8PgHyK8GB9Mo3ArBgS8Q:6347:19

    at Controller.e.safeExecuteJSNode (https://mysite.com/Job/scripts/OutSystems.js?eq9LGmzdgJbMq6dbNoVMvQ:16:7700)

    at Controller.OutSystemsMapsController.default.removeMap$Action (https://mysite.com/Job/scripts/OutSystemsMaps.controller.js?wh8PgHyK8GB9Mo3ArBgS8Q:6314:12)

    at Controller._onDestroy$Action (https://mysite.com/Job/scripts/OutSystemsMaps.Maps.Map.mvc.js?T3YTU+GttHWM5u1ffs_7Aw:568:34)

    at https://mysite.com/Job/scripts/OutSystems.js?eq9LGmzdgJbMq6dbNoVMvQ:16:18813

    at d (https://mysite.com/Job/scripts/OutSystems.js?eq9LGmzdgJbMq6dbNoVMvQ:2:16076)

    at f (https://mysite.com/Job/scripts/OutSystems.js?eq9LGmzdgJbMq6dbNoVMvQ:2:15822)

    at Object.p [as tryCatchFinally] (https://mysite.com/Job/scripts/OutSystems.js?eq9LGmzdgJbMq6dbNoVMvQ:2:16323)


I believe this is the problematic javascript in the component:

            dispose() {

                super.dispose();

                this._fBuilder.dispose();

                this._provider = undefined;

            }

From this snippet, we see that _fBuilder is only set part way through the map load:

            buildFeatures() {

                this._fBuilder = new GoogleProvider.Feature.FeatureBuilder(this);

                this._features = this._fBuilder.features;

                this._fBuilder.build();

            }

Adding a null check around this._fBuilder.dispose() would prevent this unhandled exception

Hello Mark.

First of all, thank you for reaching out.
Could you please share a sample and/or the steps to reproduce?
Which version of OutSystems Maps are you using?
Also, since our GitHub repository is public, fill free to do a PR and we'll analyze it afterwards - you're most welcome 😉

Cheers,
GM

Hi GM,

Sorry for the delay.

I've attached a (rather contrived) example. The original issue only happens intermittently, eg. if a user navigates away from a page while the map is still loading.

In this example, I am forcing the map to destroy while it is still initialising - it's the only way I could reliably trigger the error.

Thanks for pointing out the public repository, I'll submit a pull request.

-Mark

EDIT: I forgot to mention - we are using OutsystemsMaps Version 1.6.0

EDIT 2: I have submitted a PR, see https://github.com/OutSystems/outsystems-maps/pull/96

MapsDisposeIssue.oml

Hi @Mark Kranz 

Great! Thank you for your feedback and for the PR 😎
We'll analyse the code to try to check any impacts and try to replicate the issue.
We'll keep you posted.

Cheers,
GM


Hi @Mark Kranz  

Happy to inform you that your PR was accepted and was merged into the RC version 1.6.1 which has a tentative ETA of Jun 21, 2022.
Keep your feedback coming! 🚀

Cheers,
GM

Awesome, thanks Gonçalo! Much appreciated.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.