-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LWC EmpApi does not work when there is an Aura component using EmpApi #1618
Comments
To solve my issue for now I just put my LWC into another Lightning Page. It works but an odd behavior happens. When I load a page which has an Aura component that subscribes to a Platform Event using empApi and then move to another lightning page that has a LWC using empApi, this page throws an exception. If I reload this last lightning page the error is gone. |
This was once happening with me and the reason for this was that upon the
navigation the sequence of lifecycle events were not coordinated in the
navigation logic. I used state to capture current and cleared the previous
states altogether.
If your component has state before the navigation I recommend to set it to
the conducive state for the next component(page).
The other thing which might be at play here is that you are going from an
Aura component to LWC and if any of the event is set to bubble true then
that might also be causing the call back within smartstore.customer bucket
(Parent assumed hereas its ) that is probably due to a handled event down
the container hierarchy not stopped explicitly by event.stopPropagation()
…On Sat, Nov 16, 2019 at 10:18 PM AllanOricil ***@***.***> wrote:
To solve my issue for now I just put my LWC into another Lightning Page.
It works but an odd behavior happens.
When I load a page which has an Aura component that subscribes to a
Platform Event using empApi and then move to another lightning page that
has a LWC using empApi, this page throws an exception. If I reload this
last lightning page the error is gone.
This is the exception that I have:
[image: image]
<https://user-images.githubusercontent.com/55927613/68996355-bdbfd500-0890-11ea-987b-dbd775f4faf3.png>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1618?email_source=notifications&email_token=ABRIU6FWRCHPDOJDRCQO3STQUAP4BA5CNFSM4JOFDGJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEHVQVQ#issuecomment-554653782>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABRIU6CFKF2NYURL6P5OXJ3QUAP4BANCNFSM4JOFDGJA>
.
--
Regards
Mitesh Sharma
|
The components don't not communicate with each other! They are completly separated and both subscribe to different platform events. And both work when they are in separated Lightning Pages. My workaround was to transform my Aura to a LWC and everything worked perfectly. So my conclusion is, don't mix Aura and LWC components in a Lightning Page when they are both subscribing to Platform Events. This seems to be a bug. |
We're having this exact same issue in console. Our steps to reproduce:
|
By looking at the error message, this seems like a problem with proxies. Promise.prototype.then expects a branded promise object, but it is receiving a proxy of it most likely, which is not branded. This could be locker service doing the wrong thing. |
I have a suspicion this may have something to do with namespaces (at least in relation to the steps to reproduce I laid out above). I am unable to reproduce this issue when the Aura component subscribing is using the same namespace as the LWC component. |
cc @seksenov @manuel-jasso to see if he can re-route this issue to the proper queue, this is definitely not LWC. |
Any updates on when this could be fixed? In my use case, I could reproduce this in Summer pre-release org as well. My environment is set to use an already existing Background Utility Item Aura Component. And I'm building a new LWC component which needs to subscribe to a Change Data Event, now, both are conflicting, and LWC emp-api component is throwing the same error as mentioned above:
|
When I discovered this issue I wasn't using namespaces. |
seeing exactly same issue even when it is only component on page. @AllanOricil |
The Lightning Locker team is tracking and investigating the issue. When we have an update to share on potential resolutions and timeline we will do so. |
@seksenov thanks! It is appreciated |
Hi @AllanOricil, I am from Locker team, I would like to reproduce this issue, is there an environment you can point me to and steps to reproduce? Ideally, I would like to do that on my local, do you have a repo with code that I can clone and run? I understand this may be part of a large app, I'm just trying to see if we can narrow it down. Also looks like others like @joeferraro may have a similar/simpler way to reproduce? |
HI @manuel-jasso. I did it a long time ago. I will try to find the environment. But you can follow these steps to get the error.
To understand that this was a problem caused by mixing LWC and Aura components to the same lightning page, and not my code, I placed both in separate Lightning Pages, and both worked perfectly fine. But then an unexpected behavior started to happen. To reproduce this one do the following:
|
Thanks @AllanOricil, kudos to @p-wu-214 (also from Locker) who was able to repro internally, so we can debug... |
@manuel-jasso no problem. I hope it is not too hard to fix it. But you guys can do it! Good luck. Hope to hear the issue was solved soon. |
@AllanOricil Hey! An update: We debugged the problem, which was an unwrapped promise, and have a fix. Once the fix is in, we will repro the error you are running into and make sure it is working. Will keep you updated when it is tested in the environment and we backport it to an earlier release. Thank you! |
@arcadeteddy nice! well done guys. |
Hey there, any updates? |
@gyadav4 Hey, so the fixes are in! We decided on not back porting it because it touches a critical part of the filtering mechanism. |
What do you mean "not back porting"? Does it mean we can't work with aura and lwc on the same page when using the emp api? |
@AllanOricil it means that we will not fix it in current production code, but in the upcoming release only, which might take a while to hit production. |
Thanks for clarifying it @caridy |
Can this issue also occur when a custom LWC component uses emp-api and and an Aura component uses emp-api where the Aura component is in a managed package? |
@iarecuezero This can happen if you place both components on the same page. |
@caridy Hi there. Seems that we still have the issue. Could you confirm that it has not been fixed in the Winter release? Or am I wrong? |
Looks like I have the same problem :( |
If your Aura component is simple, migrate it to LWC. Just don't mix both "frameworks" and you will never have this problem |
Just added a wrapping Aura component to implement @AllanOricil, I think there may be no work-around for this case? |
|
Hi @AllanOricil, My point was that there is no way to use the documented But came back here to delete my comment as this is now all working correctly in a new scratch org so my problem was not this and the Aura/LWC mix is working for me. Sorry for the noise. |
I have a similar problem. I'm trying to subscribe to platform event using empApi in my lwc component, but its not subscribing. My requirement is to take action based on the event received. With my usecase, I have to put this lwc into an VF page and have to use aura component to achieve this. |
@AllanOricil That's not how Salesforce works... If the Aura component is part of a managed package, you obviously cannot migrate it... |
Description
LWC can't subscribe to a Platform Event if there is an Aura component that is subscribing to a Platform event in the same Lightning Page.
Steps to Reproduce
Place an Aura component that subscribes to a Platform Event 1 and a LWC that subscribes to a Platform Event 2 in a Lightning Page. The Aura component subscribed without any problem. The LWC did not subscribe and also did not display any error message or exception. Once I removed the Aura component from the Lightning Page, saved it, and reloaded it, the LWC subscribed to the Platform Event. Bear in mind I did not change anything in the LWC. I just removed the Aura component from the Lightning Page.
I followed the instructions to build the LWC component from here:
https://developer.salesforce.com/docs/component-library/bundle/lightning-emp-api/documentation
And I made the correction to my component that is described here:
https://developer.salesforce.com/forums/ForumsMain?id=9062I000000Xm9eQAC
Again, the LWC code is working! but only if I remove the Aura component from the Lightning Page.
Expected Results
LWC should subscribe to the Platform Event
Actual Results
LWC does not subscribe to the Platform Event and also does not show an errror message or exception
The text was updated successfully, but these errors were encountered: