Skip to content

Commit 6bb1fa9

Browse files
Tom KirkpatrickTom Kirkpatrick
Tom Kirkpatrick
authored and
Tom Kirkpatrick
committed
fix: workaround for loopback 2.x circular json error
1 parent f2f60ee commit 6bb1fa9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/mixins/state-machine.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,17 @@ module.exports = function StateMachine(Model, settings) {
156156
// Run the event method.
157157
return fms[eventName](this, ...args)
158158
.then(result => result)
159+
.catch(err => {
160+
if (Model.app.loopback.version.startsWith(2)) {
161+
try {
162+
JSON.stringify(err)
163+
}
164+
catch (e) {
165+
_.unset(err, 'error@context.http')
166+
}
167+
}
168+
throw err
169+
})
159170
.finally(() => Model.app.deleteStateMachine(this))
160171
}
161172
})

0 commit comments

Comments
 (0)