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

TypeError: Cannot read properties of null (reading 'type') #459

Open
mquadrant opened this issue Apr 3, 2022 · 3 comments
Open

TypeError: Cannot read properties of null (reading 'type') #459

mquadrant opened this issue Apr 3, 2022 · 3 comments

Comments

@mquadrant
Copy link

I am getting error when running the scrapper function in a cron, and throw the error at the second run.

TypeError: Cannot read properties of null (reading 'type') at Object.createResource

async function secretAgentFunction({ url }) {
    await agent.goto(url);
    console.log('Running ----- ', url)
    await agent.close();
}
@blakebyrnes
Copy link
Contributor

@mquadrant - I can't see your whole code snippet, but are you using the default agent that comes from const agent = require('secret-agent')? If you are, and this function is being called twice, it looks like you might be closing it and then trying to reuse it. You should move this to use a handler, or just construct a new Agent each time. Hopefully this helps!

@mquadrant
Copy link
Author

@blakebyrnes I tried using the handler without closing the handlers and it works for 10 runs and then it throws this MaxListenersExceededWarning: Possible EventEmitter memory leak detected.
While closing the agent/handler throw TypeError: Cannot read properties of null (reading 'type') at Object.createResource on the second run.

@blakebyrnes
Copy link
Contributor

The max listeners message is just a warning. We probably need to look into that, but it shouldn't be causing any side effects.

Would you might sharing a full code sample and which url you're seeing this on? (You're welcome to send to me on or Discord channel if you're not comfortable putting on github).

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