Callback function is not invoked when using buffering with JavaScript remoting after logging out
Last updated 2017-05-09 ·Reference W-3589029 ·Reported By 3 users
Summary
Callback function is not invoked when using buffering with JavaScript remoting after logging out. However, it is supposed to be invoked with error status.
Repro
1. create the following Apex class
---
public class W3584852 {
@RemoteAction
public static Account getAccount() {
return [SELECT Id, Name FROM Account LIMIT 1];
}
}
---
2. create the following Visualforce page
Name : W3584852
---
<apex:page controller="W3584852">
<script>
function hello() {
clear();
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.W3584852.getAccount}',
handleResponse1,
{ buffer: true }
);
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.W3584852.getAccount}',
handleResponse2,
{ buffer: true }
);
}
function helloWithoutBuffering() {
clear();
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.W3584852.getAccount}',
handleResponse1,
{ buffer: false }
);
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.W3584852.getAccount}',
handleResponse2,
{ buffer: false }
);
}
function clear() {
document.getElementById('message1').textContent = null;
document.getElementById('message2').textContent = null;
}
function handleResponse1(result, event) {
handleResponse(result, event, 'message1', 'handleResponse1 is triggered!!');
}
function handleResponse2(result, event) {
handleResponse(result, event, 'message2', 'handleResponse2 is triggered!!');
}
function handleResponse(result, event, id, msg) {
alert(msg);
if (event.status) {
var message = document.getElementById(id);
message.textContent = result.Name;
} else {
alert(event.message);
}
}
</script>
<div id='message1'></div>
<div id='message2'></div>
<button onclick='hello(); return false;'>With Buffering</button>
<button onclick='helloWithoutBuffering(); return false;'>Without Buffering</button>
</apex:page>
---
3. view the above Visualforce page
5. preview the above Visualforce page
You will see the above Visualforce is opened in a new window/browser tab.
And you will see "With Buffering" button and "Without Buffering" button.
6. move back to a window/browser tab which is viewing Visualforce page
7. logout in the window/browser tab
8. move back to the window/browser tab which is previwing Visualforce page
9. click "Without Buffering" button
You will see alert dialog is opened. This is expected.
10. click "With Buffering" button
You will not see alert dialog is opened.
Javascript error in browser console:
==============
Uncaught TypeError: Cannot read property 'tid' of undefined
at constructor.getTransaction (VFRemote.js:4970)
at sb.getTransaction (VFRemote.js:5047)
at constructor.<anonymous> (VFRemote.js:7373)
at EXTUTIL.Event.fire (VFRemote.js:3035)
at constructor.fireEvent (VFRemote.js:2680)
at constructor.onData (VFRemote.js:5401)
at VFExt3.data.Connection.handleResponse (VFRemote.js:4243)
at handleTransactionResponse (VFRemote.js:2261)
at VFRemote.js:2326
==============
Workaround
Avoid using buffering.
Reported By (3)
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.