What can cause a serverside table to load initially but not paginate?
What can cause a serverside table to load initially but not paginate?
Error:
Unhandled promise error: [object Promise]AggregateError: select [EventDate] as [EventDate], [ToolID] as [ToolID], [ToolName] as [ToolName], [EventType] as [EventType], [Status] as [Status], [UserName] as [UserName], [Comment] as [Comment], [CodeValue] as [CodeValue], [PlanName] as [PlanName], [ToolEventID] as [ToolEventID], [AreaID] as [AreaID], [Official] as [Official] from [fact].[vwToolEventsTable] where [Official] = @p0 and [AreaID] = @p1 offset @p2 rows fetch next @p3 rows only -
stack: AggregateError: select [EventDate] as [EventDate], [ToolID] as [ToolID], [ToolName] as [ToolName], [EventType] as [EventType], [Status] as [Status], [UserName] as [UserName], [Comment] as [Comment], [CodeValue] as [CodeValue], [PlanName] as [PlanName], [ToolEventID] as
[ToolEventID], [AreaID] as [AreaID], [Official] as [Official] from [fact].[vwToolEventsTable] where [Official] = @p0 and [AreaID] = @p1 offset @p2 rows fetch next @p3 rows only -
at RequestTokenHandler.onErrorMessage (C:\**********\node_modules\tedious\src\token\handler.ts:402:30)
at Readable.<anonymous> (C:\**********\node_modules\tedious\src\token\token-stream-parser.ts:22:7)
at Readable.emit (node:events:527:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:297:9)
at Readable.push (node:internal/streams/readable:234:10)
at next (node:internal/streams/from:98:31)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
Description:
Hi, the application I'm developing contains multiple pages with server driven Datatables on a html template. About half of them work, no problem with paging. However, like the title says, all of the datatables load initially, but some don't load any additional pages. I'm using the nodejs editor-server package as the base project. When attempting to navigate to a new page in a datatable, making a call to the node server, I get an unhandled promise error which I cannot really decipher. I will include a code snippet from one template that works and another that doesn't. I will also include the corresponding server snippets. The first two snippets are from a table which does work, the following two snippets are from a table which loads initially but doesn't work after that. I could not see a difference which would cause the different functionality. I don't have use for the editor component, so the editor server is in trial mode I believe. Will share any other needed information. Has anyone encountered this?
router.all('/api/events',cors(), async function(req, res) {
var currArrea = (req.body.areaid)
let editor = new Editor(db, 'fact.vwEventsTable','EventDate')
.fields(
new Field('EventDate'),
new Field('UserName'),
new Field('EventType'),
new Field('CodeValue'),
new Field('OpOrder'),
//new Field('AreaID'),
new Field('ProdOrder'),
new Field('LotName'),
new Field('SubLotName'),
new Field('EventDetail'),
new Field('ItemName'),
new Field('Comment'),
new Field('LotID'),
new Field('TrackingID'),
new Field('Official'),
).where('Official',1)//.where('AreaID',currArrea)
await editor.process(req.body);
res.json(editor.data());
});
$('#eventtable').DataTable( {
"order": [],
"lengthMenu": [[40, 80, 120, -1], [40, 80, 120, "All"]],
stateSave: true,
serverside:true,
ajax:{
url:'http://localhost:8081/api/events',
contentType: "application/json",
type:'POST',
data: function (d){
d.areaid = Number('{{area}}')
}
}
router.all('/api/toolevents',cors(), async function(req, res) {
var currArrea = (req.body.areaid)
var flag = (req.body.flag)
let editor = new Editor(db, 'fact.vwToolEventsTable','EventDate')
.fields(
new Field('ToolID'),
new Field('ToolName'),
new Field('EventType'),
new Field('Status'),
new Field('EventDate'),
new Field('UserName'),
new Field('Comment'),
new Field('CodeValue'),
new Field('PlanName'),
new Field('ToolEventID'),
new Field('AreaID'),
new Field('Official'),
).where('Official',1).where('AreaID',currArrea)
await editor.process(req.body);
res.json(editor.data());
});
$('#eventtable').DataTable( {
"order": [],
"lengthMenu": [[40, 80, 120, -1], [40, 80, 120, "All"]],
stateSave: true,
serverSide: true,
ajax:{
url:'http://localhost:8081/api/toolevents',
//url:'/api/process/eventstable',
//contentType: "application/json",
type:'POST',
data: function (d){
d.areaid = Number('{{area}}')
d.flag = Number('{{flag}}')
}
}
,
Answers
Nor I!
Unfortunately, I'm the same! The only difference I really see is
//contentType: "application/json",
is commented out in the second, by I presume you've tried that?The server-side component for Editor is open source - MIT licensed. Just avoid loading the Editor client-side script and the server-side code will run forever.
The frustrating thing about that error message is that it doesn't actually appear to say anything about what caused the error. There is an unhandled Promise exception - but what caused that...?!
If you
console.log(req.body);
- what does that look like when the request that fails happens?Allan
I don't know why it works like this, but I have found how to make the table paging work. When the page initially loads and the table is loaded, the paging does not work, however when I click a column and sort, all of the functionality resumes. I tested this on all my broken templates and it worked.