Skip to content

Commit

Permalink
Add OOM test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonTian committed Jul 4, 2017
1 parent 2947b3f commit 6fb5e65
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/application.js
Expand Up @@ -80,7 +80,7 @@ class Application extends EggApplication {
this[LOCALS] = {};
}

assign(this[LOCALS], [ val ]);
assign(this[LOCALS], val);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions test/app/extend/application.test.js
Expand Up @@ -77,6 +77,12 @@ describe('test/app/extend/application.test.js', () => {
.get('/app_same_ref')
.expect('true');
});

it('should app.locals not OOM', () => {
return app.httpRequest()
.get('/app_locals_oom')
.expect('ok');
});
});

describe('app.createAnonymousContext()', () => {
Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/apps/locals/app/router.js
Expand Up @@ -14,6 +14,16 @@ module.exports = app => {
this.body = app1 === app2;
});

app.get('/app_locals_oom', function*() {
for (let i = 0; i < 1000; i++) {
app.locals = {
// 10MB
buff: Buffer.alloc(10 * 1024 * 1024).toString()
};
}
this.body = 'ok';
});

app.get('/ctx_same_ref', function*() {
let ctx1, ctx2;
this.locals = {
Expand Down

0 comments on commit 6fb5e65

Please sign in to comment.