This.res.status is not a function

I'm diving into more logging and noticing lots of these:

TypeError: this.res.status is not a function
    at App.response (/opt/node_app/lib/modules/core.js:223:22)
    at App._exec (/opt/node_app/lib/core/app.js:722:49)
    at App.exec (/opt/node_app/lib/core/app.js:655:16)
    at App.condition (/opt/node_app/lib/modules/core.js:135:28)
    at App._exec (/opt/node_app/lib/core/app.js:722:49)
    at App._exec (/opt/node_app/lib/core/app.js:689:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async App.exec (/opt/node_app/lib/core/app.js:655:5)
    at async App.condition (/opt/node_app/lib/modules/core.js:135:17)
    at async App._exec (/opt/node_app/lib/core/app.js:722:22)

Bug? Or am I triggering this somehow?

Think we need some context there. Where are you seeing this?

I use res.status a lot in server extensions, never had an issue

Do you call some server actions using the scheduler?

Yes, the scheduler is where I've been looking. My scheduler actions do api calls, db updates, etc. but I couldn't find any Response actions, which to me could be a culprit. That being said, I do have things touching custom extensions like bull queues, etc. so it is definitely possible I have just missed something like that.

Searching my project, the only references to this.res.status are the dmx uses (ratelimit.js, core.js, etc.)

We have a simple mockup response object that is being used there to prevent most errors and it should have the status method on it.

Check the file lib/setup/cron.js, it should have the following code in it:

function exec(action) {
    return async () => {
        const App = require('../core/app');
        const app = new App({
            params: {},
            session: {},
            cookies: {},
            signedCookies: {},
            query: {},
            headers: {}
        }, {
            headersSent: false,
            set() {},
            status() { return this; },
            send() { this.headersSent = true; },
            json() { this.headersSent = true; },
            redirect() { this.headersSent = true; }
        });
        return app.define(action, true);
    }
}

The second argument to the App constructor is the mockup response object which has all the important methods on it.

Mine seems to match:

function exec(action) {
    return async () => {
        const App = require('../core/app');
        const app = new App({
            params: {},
            session: {},
            cookies: {},
            signedCookies: {},
            query: {},
            headers: {}
        }, {
            headersSent: false,
            set() {},
            status() { return this; },
            send() { this.headersSent = true; },
            json() { this.headersSent = true; },
            redirect() { this.headersSent = true; }
        });
        return app.define(action, true);
    }
}

Are you saying I should be able to do something with that in order to troubleshoot?

It would be helpful if you could figure out which server action is throwing the error and which action steps are in it.