Skip to content

Commit 5a5d7d9

Browse files
committed
force end() to be final allowable call
1 parent 299d7c4 commit 5a5d7d9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/debug.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,13 @@ function createDebug(namespace) {
130130
// that float must be the delta time in milliseconds.
131131
var args = arguments;
132132
var beginTime = exports.hrtime();
133+
var ended = false;
133134

134135
var mark = function (title, extraArgs) {
136+
if (ended) {
137+
return;
138+
}
139+
135140
section.title = title;
136141
section.deltaTime = exports.hrtime(beginTime);
137142
if (extraArgs.length) {
@@ -147,7 +152,11 @@ function createDebug(namespace) {
147152
var section = {
148153
title: '[begin]',
149154
end: function () {
150-
return mark('[end]', arguments);
155+
try {
156+
return mark('[end]', arguments);
157+
} finally {
158+
ended = true;
159+
}
151160
},
152161
mark: function () {
153162
return mark('[mark]', arguments);

0 commit comments

Comments
 (0)