I have an LWC FSC (flow screen component).
I am trying to subscribe to a CDC event, but the subscription never seems to execute.
The same LWC when displayed on a lightning record page does subscribe to the CDC event.
Is there a restriction that stops FSCs from being able to subscribe to CDC events?
import { LightningElement } from 'lwc';
import { subscribe } from 'lightning/empApi';
export default class MySubscribeTest extends LightningElement {
subscription;
connectedCallback() {
console.log('this definitely runs');
const messageCallback = (response) => {
console.log('New message received: ', JSON.stringify(response));
};
// the then/catch blocks are never executed
subscribe('/data/My_Custom_Object__ChangeEvent', -1, messageCallback)
.then((response) => {
// Response contains the subscription information on subscribe call
console.log(
'Subscription request sent to: ',
JSON.stringify(response.channel)
);
this.subscription = response;
})
.catch((error) => {
console.dir(error);
});
}
}