#afterChange global hook is called twice??

9 messages ยท Page 1 of 1 (latest)

hollow imp
#

The hook is run twice after data is saved.

gray heron
#

Thanks for the report. This does appear to be a bug. I'll get a fix going ๐Ÿ‘

hollow imp
gray heron
#

I would say next couple of days. I have a fix branch created, just needs some testing

twin finch
#

A temporary fix but I just used a boolean to trigger one deploy

let UPDATED = false;
...
    hooks: {
        afterChange: [async () => {
            if(process.env.NODE_ENV === "production" && !UPDATED) {
                UPDATED = true;
                await fetch(process.env.CLOUDFLARE_HOOK_URL, {
                method: 'POST'
                }).then(res => res.ok ? res.json() : Promise.reject(res))
                    .catch(err => console.error(err)); 
            } else if(UPDATED) {
                UPDATED = false;
            }
        }]
    }
gray heron
#

The fix has been merged and will be in the next release. That'll likely be this week, not sure when yet though - since we're doing our Launch Week.

hollow imp
gray heron