-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add timeout function to limit processing time
- Loading branch information
Showing
10 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
|
||
const sharp = require('../../'); | ||
const fixtures = require('../fixtures'); | ||
|
||
describe('Timeout', function () { | ||
it('Will timeout after 1s when performing slow blur operation', () => assert.rejects( | ||
() => sharp(fixtures.inputJpg) | ||
.blur(100) | ||
.timeout({ seconds: 1 }) | ||
.toBuffer(), | ||
/timeout: [0-9]+% complete/ | ||
)); | ||
|
||
it('invalid object', () => assert.throws( | ||
() => sharp().timeout('fail'), | ||
/Expected object for options but received fail of type string/ | ||
)); | ||
|
||
it('invalid seconds', () => assert.throws( | ||
() => sharp().timeout({ seconds: 'fail' }), | ||
/Expected integer between 0 and 3600 for seconds but received fail of type string/ | ||
)); | ||
}); |