Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in persist timestamps #16

Open
eddiecooro opened this issue Mar 26, 2018 · 2 comments
Open

Bug in persist timestamps #16

eddiecooro opened this issue Mar 26, 2018 · 2 comments

Comments

@eddiecooro
Copy link

eddiecooro commented Mar 26, 2018

Hi
when i set persist to true orm-timestamp throws a "Maximum call stack size exceeded" error

Here is full stack trace and error:

(node:7632) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): RangeError: Maximum call stack size exceeded
(node:7632) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the
 Node.js process with a non-zero exit code.
RangeError: Maximum call stack size exceeded
    at Object.now (C:\actcustomer\node_modules\orm-timestamps\lib\orm-timestamps.js:7:16)
    at Object.<anonymous> (C:\actcustomer\node_modules\orm-timestamps\lib\orm-timestamps.js:81:46)
    at Object.exports.wait (C:\actcustomer\node_modules\orm\lib\Hook.js:19:26)
    at saveInstanceProperty (C:\actcustomer\node_modules\orm\lib\Instance.js:422:10)
    at Object.set [as modified_at] (C:\actcustomer\node_modules\orm\lib\Instance.js:521:11)
    at Object.<anonymous> (C:\actcustomer\node_modules\orm-timestamps\lib\orm-timestamps.js:81:36)
    at Object.exports.wait (C:\actcustomer\node_modules\orm\lib\Hook.js:19:26)
    at saveInstanceProperty (C:\actcustomer\node_modules\orm\lib\Instance.js:422:10)
    at Object.set [as modified_at] (C:\actcustomer\node_modules\orm\lib\Instance.js:521:11)
    at Object.<anonymous> (C:\actcustomer\node_modules\orm-timestamps\lib\orm-timestamps.js:81:36)
    at Object.exports.wait (C:\actcustomer\node_modules\orm\lib\Hook.js:19:26)
    at saveInstanceProperty (C:\actcustomer\node_modules\orm\lib\Instance.js:422:10)
    at Object.set [as modified_at] (C:\actcustomer\node_modules\orm\lib\Instance.js:521:11)
    at Object.<anonymous> (C:\actcustomer\node_modules\orm-timestamps\lib\orm-timestamps.js:81:36)
    at Object.exports.wait (C:\actcustomer\node_modules\orm\lib\Hook.js:19:26)
    at saveInstanceProperty (C:\actcustomer\node_modules\orm\lib\Instance.js:422:10)
Maximum call stack size exceeded
@notheotherben
Copy link
Owner

Hi @Eddie-CooRo, I'm afraid I haven't seen this before, however it looks like the issue stems from you having autoSave enabled on your object. This means that as soon as this plugin changes the modified_at field, orm's Instance attempts to save the new changes - this obviously continues ad-infinitum until you end up with a stack overflow.

I, unfortunately, can't see a way to make a plugin like this work with autoSave enabled so my advice is going to be to either disable autoSave and manually trigger saving of your instances (which is likely going to reduce the number of queries you make to the DB anyway) or manually manage the modified_at timestamp.

Sorry I can't be of more help

@eddiecooro
Copy link
Author

Thank you so much
I didn't know that it's because of autosave...
I'll look for a workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants