Unable to interact with element using selenium after connecting to remote debugging Frontend URL

I am unable to interact with element in UI after connecting to devtoolsFrontendUrl after using remote-debugging. But issue is not faced if I have not connected to devtoolsFrontendUrl.

My script:

 webdriver = require("selenium-webdriver");
   const chrome = require("selenium-webdriver/chrome");
   let opts = new chrome.Options();
   opts.addArguments("remote-debugging-port=9222")
   opts.addArguments("headless")
   opts.addArguments("remote-debugging-address=0.0.0.0")
   opts.addArguments("window-size=1920,1080")
   const { Builder, Capabilities } = webdriver;
   let capabilities = Capabilities.chrome();
   driver = await new Builder()
   .usingServer("http://localhost:4444/wd/hub")
   .withCapabilities(capabilities)
   .setChromeOptions(opts)
   .build();
 await driver.get("My URL")

After that I am able to access the url in a chrome browser localhost:9222/json

I get the JSON as below:

[ {
   "description": "",
   "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9222/devtools/page/5C9612F350A70AF13943240DE0B1EF05",
   "id": "5C9612F350A70AF13943240DE0B1EF05",
   "title": "title",
   "type": "page",
   "url": "myURL",
   "webSocketDebuggerUrl": "ws://localhost:9222/devtools/page/5C9612F350A70AF13943240DE0B1EF05"
}, {
   "description": "",
   "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9222/devtools/page/FB791E87874704F96453713AB412C02C",
   "id": "FB791E87874704F96453713AB412C02C",
   "title": "about:blank",
   "type": "page",
   "url": "about:blank",
   "webSocketDebuggerUrl": "ws://localhost:9222/devtools/page/FB791E87874704F96453713AB412C02C"
} ]

Then I connect to devtools frontend URL: http://localhost:9222/devtools/inspector.html?ws=localhost:9222/devtools/page/5C9612F350A70AF13943240DE0B1EF05

After connecting to the above url I get the remote display of the URL which I have opened using selenium along with the devtools but I am not able to perform a click on the element using selenium using below code:

driver.findElement(webdriver.By.xpath(`//button[contains(text(),'Sign In')]`)).click();

But it works if I am not connected to devtoolsFrontendUrl.

Please Help!!!

I tried alternative solution using puppeteer in place of selenium still I face the same issue.