cancel
Showing results for 
Search instead for 
Did you mean: 

CAP NodeJS: Rest Adapter usage with large JSON object leads to 413 - Payload Too Large

martinstenzig
Contributor

What is the best way to increase the message size limitation on the REST adapter?

Temporarily adjusting line 110 in cds/libx/rest/RestAdapter.js

from -> router.use(express.json()) // REVISIT: -> belongs to the parses
to -> router.use(express.json({limit:"50mb"}))

fixes the problem, but what is the appropriate way of working around that limitation?

martinstenzig
Contributor
0 Kudos

Thinking about it a little further. I think there could be 2 long term solutions.

1. A require parameter for the adapter that one can set via cds.env

2. A service level annotation that would allow for the following

@protocol: 'rest'
@messageSize: '50mb'
service MassChangeService {

@open
type AnyArray {};

action insertAll(insEntity : String, insArray: AnyArray) returns AnyArray;

}
View Entire Topic
Daniel7
Advisor
Advisor
0 Kudos

As there will always be a next limit reached, and materializing such large payloads has detrimental effects on resource consumption, I think we need some kind of ootb streaming support for such scenarios, which we don’t have today. → subject for further imp

martinstenzig
Contributor
0 Kudos

daniel.hutzel, Sounds like a plan.

By the way, I was not necessarily suggesting 10MB message sizes, but what I tripped over is that the same message size that does not cause a problem for an OData call, seems to break the Rest adapter.