get-windows icon indicating copy to clipboard operation
get-windows copied to clipboard

UnhandledPromiseRejectionWarning: SyntaxError: Unexpected number in JSON at position 10

Open SarathKmrM opened this issue 2 years ago • 8 comments

Hi team

The module is working fine, but I am getting errors on some specific sites and applications. I am getting below error on https://gitlab.com/users/sign_in Open above link on the browser and try to get activeWindow(), you can find this error

(node:16684) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected number in JSON at position 10
    at JSON.parse (<anonymous>)
    at parseLinux (/var/www/html/focusro-electron-app-apptrack/focusro-app/node_modules/active-win/lib/linux.js:49:15)
    at getWindowInformation (/var/www/html/focusro-electron-app-apptrack/focusro-app/node_modules/active-win/lib/linux.js:92:15)
    at async Timeout._onTimeout (/var/www/html/focusro-electron-app-apptrack/focusro-app/electron-main.js:455:28)
(node:16684) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)

Why is this happening ? any solutions ? I am using 8.0.2 version. thanks in advance

SarathKmrM avatar Dec 29 '22 11:12 SarathKmrM

+1

seantaylorgmi avatar Dec 30 '22 05:12 seantaylorgmi

+1

shunmuga-sundaram avatar Dec 30 '22 12:12 shunmuga-sundaram

+1

richardkevinbox avatar Jan 25 '23 13:01 richardkevinbox

i am also facing this issue

samkennardg avatar Jan 25 '23 14:01 samkennardg

+1

ReginaLisa avatar Jan 25 '23 14:01 ReginaLisa

+1

nikess avatar Mar 21 '23 19:03 nikess

+1

sarathkmrdev avatar Mar 23 '23 06:03 sarathkmrdev

https://github.com/sindresorhus/active-win/blob/27221e5da0a64025bdec8759605694ea84ff9f68/lib/linux.js#L47-L54

I meet the same problem, after some debug, I change to

	return {
		platform: 'linux',
		title: result['_NET_WM_NAME(UTF8_STRING)'] || result['WM_NAME(STRING)'] || null,
		id: windowId,
		owner: {
			name: result['WM_CLASS(STRING)'].split(',').pop(),
			processId
		},

well, at least it kind of works.

{
  platform: 'linux',
  title: '"apptimer : apptimer \\342\\200\\224 Konsole"',
  id: 150994959,
  owner: { name: ' "konsole"', processId: 169925, path: '/usr/bin/konsole' },
  bounds: { x: 0, y: 42, width: 1920, height: 994 },
  memoryUsage: 217608192
}


about windowId, I found that it will have some problems when listening to a browser or a wine app. For example: become undefined.


and doesn't support CJK


asukaminato0721 avatar May 04 '23 16:05 asukaminato0721