Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit 2a131c2

Browse files
Correct the status shown if maxDataSize is reached (#173)
If a watched expression is collected that causes the `config.capture.maxDataSize` limit to be reached, local variables may not be collected, but the status message associated with the local variable would be incorrect. In particular, if the local was an array, the message would describe that only the first `config.capture.maxProperties` items were captured. This PR corrects this so that the status message is instead 'Max data size reached'.
1 parent d370e20 commit 2a131c2

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

lib/state.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ StateResolver.prototype.trimVariableTable_ = function(fromIndex, frames) {
218218
if (variable.varTableIndex && variable.varTableIndex >= fromIndex) {
219219
// make it point to the sentinel 'buffer full' value
220220
variable.varTableIndex = BUFFER_FULL_MESSAGE_INDEX;
221+
variable.status = MESSAGE_TABLE[BUFFER_FULL_MESSAGE_INDEX].status;
221222
}
222223
if (variable.members) {
223224
processBufferFull(variable.members);

test/test-v8debugapi.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,43 @@ describe('v8debugapi', function() {
870870
});
871871
});
872872

873+
it('should set the correct status messages if maxDataSize is reached',
874+
function(done) {
875+
var bp = {
876+
id: 'fake-id-124',
877+
location: { path: 'test-v8debugapi.js', line: 5 },
878+
expressions: ['A']
879+
};
880+
var oldMaxProps = config.capture.maxProperties;
881+
var oldMaxData = config.capture.maxDataSize;
882+
config.capture.maxProperties = 1;
883+
config.capture.maxDataSize = 1;
884+
api.set(bp, function(err) {
885+
assert.ifError(err);
886+
api.wait(bp, function(err) {
887+
assert.ifError(err);
888+
889+
var bResults = bp.stackFrames[0].locals.filter(function(value) {
890+
return value.name === 'B';
891+
});
892+
assert(bResults);
893+
assert.strictEqual(bResults.length, 1);
894+
895+
var bArray = bResults[0];
896+
assert(bArray);
897+
assert(bArray.status.description.format.indexOf(
898+
'Max data size reached') !== -1);
899+
assert(bArray.status.isError);
900+
901+
api.clear(bp);
902+
config.capture.maxDataSize = oldMaxData;
903+
config.capture.maxProperties = oldMaxProps;
904+
done();
905+
});
906+
process.nextTick(function() {foo(2);});
907+
});
908+
});
909+
873910
it('should capture without values for invalid watch expressions', function(done) {
874911
// clone a clean breakpointInFoo
875912
var bp = {

0 commit comments

Comments
 (0)