Skip to content

TargetCloseError when calling gtc.find() - Browser closes prematurely #12

@CmetankaJDD

Description

@CmetankaJDD

Description

After successfully logging in, the gtc.find() method throws a TargetCloseError. The browser closes prematurely before the selector .box.r-profile-box can be found.

Steps to Reproduce

  1. Initialize Gtc with headless puppeteer
  2. Login successfully (QR code scan)
  3. Call gtc.find('ID', '6283812345678')
  4. Error occurs

Code

const { Gtc } = require('gtc-js')

const gtc = new Gtc({
  cookiePath: './cookie.json',
  showQr: false,
  puppeteer: {
    headless: true,
    args: ['--no-sandbox', '--disable-setuid-sandbox'],
  },
})

gtc.on('logged', async (logged) => {
  if (logged) {
    const tags = await gtc.find('ID', '6283812345678')
    console.log(tags)
  }
})

await gtc.init()

Error

TargetCloseError: Waiting for selector `.box.r-profile-box` failed: Protocol error (Runtime.callFunctionOn): Target closed

Environment

  • Node.js: v24.11.1
  • gtc-js: latest
  • puppeteer: 22.15.0
  • OS: Ubuntu 24.04 (codespace)

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions