-
Notifications
You must be signed in to change notification settings - Fork 78
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
Status fetch error SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse #276
Comments
Also getting this error... Following for updates |
i found a fix and a work around. then after const currentUrl = redirectString || requestUrl; I added the following. then restart the plugin. |
on your system, it's different, you can see your error message points to /usr/local/lib/node_modules/homebridge-hyundai-bluelink/node_modules/got/source/request-as-event-emitter.js, give the change a try and let me know how you do. at ClientRequest. (/usr/local/lib/node_modules/homebridge-hyundai-bluelink/node_modules/got/source/request-as-event-emitter.js:178:14) |
this work around is in place of changing /etc/ssl/openssl.cnf since this code does not use the openssl config. the api site has changed their servers to not allow renegotiate as you can see from the EPROTO error message unsafe legacy renegotiation disabled |
request-as-event-emitter.js.zip |
Thank you for the fast response. Minutes after I send the message I was able to find the file. Let me give you a little bit of background on the issues people in the USA have. Months ago we started getting this error if we had node.js above node 16. To avoid that issue I stayed at Node.js 16. But now we have this error: Status fetch error SyntaxError: Unexpected token < in JSON at position 0 I applied your work around but I still have the an error Status fetch error SyntaxError: Unexpected token < in JSON at position 0 using node 21 and bluelinky 8.3.1 I get: Client Error SyntaxError: Unexpected token '<', " what version of node.js and bluelinky are you using? are you in the USA? Thank you for your time. I really appreciate you responding to this issue |
the error you get is because of a server change. I'm in the USA. Error: Client Error GotError [RequestError]: write EPROTO 00FAF1B6:error:0A000152:SSL routines:final_renegotiate:unsafe legacy renegotiation disabled:../deps/openssl/openssl/ssl/statem/extensions.c:922: unless you fix the error it will lead to Status fetch error SyntaxError: Unexpected token < in JSON at position 0 can you share your versions of node and also the full error stack messages. |
did you try the debug test?
? What Region are you in? US ? What you wanna do? lock ? What you wanna do? exit |
Hello @cmorozcogmailcom, I am using node 16.20.2 on a raspberry pi, bluelinky version is 7.6.6 (but I also get the error with 8.3.1). Client Ready I am not sure how to run this: Thank you for the help and if you need anything else let me know |
follow https://github.com/Hacksore/bluelinky to run the debug.ts script with npm run debug, also you can read up on it here https://bluelinky.readme.io/reference/installation |
I run the commands and this is what I go but I don't know if I did it right : guamis@Guamiss-Mac-Mini bluelinky % npm run debug
/Users/guamis/node_modules/bluelinky/node_modules/ts-node/src/index.ts:513 2 import got from 'got'; node_modules/@types/got/index.d.ts:25:1
I am sugin version Hyundai Bluelink 1.4.1 but I did a lot of modifications to the plugin. I added a bunch of sensors and information in the form of TV inputs. When the plugin used to work all the of the information in the picture below was populated ![]() Do you think there is a path to make this work again? Unfortunately I am not experienced enough to solve my error so I would definitely appreciate all the help I can get |
it's likely you broke it with your mods, the data types you may have added may not be in the bluelinkly types. for example: the odometer is not working looks like bugs in bluelinky. [email protected] debug
? What Region are you in? US ? What you wanna do? stop ? What you wanna do? odometer ? What you wanna do? (Use arrow keys) i also fixed the vehicle status ? What you wanna do? status (on server cache) What you wanna do? status (on server cache) ** unparsed What you wanna do? locate |
i'd like to ask how you added the controls and sensors to the plugin ? |
Hello @cmorozcogmailcom, I am actually doing all the debug/testing in an unmodified version of bluelinky so my mods are not causing the problem. I will give ts-node. About the plugin, I added a bunch of things to the Hyundai Bluelink homebridge plugin. in dist/services/index.js you can add/remove any service you like by editing this line: const services = [new lock_1.Lock(va), new motor_1.Motor(va), new ignition_1.Ignition(va), new milage_1.Milage(va), new refill_1.Refill(va), new currentStatus_1.CurrentStatus(va), new odometer_1.Odometer(va), new oilSensor_1.OilSensor(va), new oil_1.Oil(va), new trunk_1.Trunk(va), new doors_1.Doors(va), new hood_1.Hood(va), new oilService_1.OilService(va), new palisade_1.Palisade(va), new palisade1_1.Palisade1(va), new palisade2_1.Palisade2(va), new palisade3_1.Palisade3(va), new palisade4_1.Palisade4(va), new palisade5_1.Palisade5(va), new palisade6_1.Palisade6(va), new palisade7_1.Palisade7(va), new palisade8_1.Palisade8(va), new palisade9_1.Palisade9(va), new palisade10_1.Palisade10(va), new palisade11_1.Palisade11(va), new palisade12_1.Palisade12(va), new palisade13_1.Palisade13(va), new palisade14_1.Palisade14(va), new palisade15_1.Palisade15(va)]; I also created a second homebridge plugin because for some reason the TV accessory in this one was not showing the inputs I would be happy to walk you through it if you are interested in the plugin. |
I installed ts-node but I still have the same error, most likely I am not doing it right. However, I was able to run the debug.ts file and this is what I got. guamis@Guamiss-Mac-Mini Bluelinky % tsc debug.ts 3 import got from 'got'; node_modules/@types/got/index.d.ts:25:1 src/controllers/american.controller.ts:2:8 - error TS1259: Module '"/Users/guamis/node_modules/bluelinky/node_modules/@types/got/index"' can only be default-imported using the 'esModuleInterop' flag 2 import got from 'got'; node_modules/@types/got/index.d.ts:25:1 src/controllers/australia.controller.ts:1:8 - error TS1259: Module '"/Users/guamis/node_modules/bluelinky/node_modules/@types/got/index"' can only be default-imported using the 'esModuleInterop' flag 1 import got, { GotInstance, GotJSONFn } from 'got'; node_modules/@types/got/index.d.ts:25:1 src/controllers/authStrategies/australia.authStrategy.ts:1:8 - error TS1259: Module '"/Users/guamis/node_modules/bluelinky/node_modules/@types/got/index"' can only be default-imported using the 'esModuleInterop' flag 1 import got from 'got'; node_modules/@types/got/index.d.ts:25:1 src/controllers/authStrategies/australia.authStrategy.ts:4:8 - error TS2613: Module '"url"' has no default export. Did you mean to use 'import { Url } from "url"' instead? 4 import Url from 'url'; src/controllers/authStrategies/authStrategy.ts:1:8 - error TS1259: Module '"/Users/guamis/node_modules/bluelinky/node_modules/@types/got/index"' can only be default-imported using the 'esModuleInterop' flag 1 import got from 'got'; node_modules/@types/got/index.d.ts:25:1 src/controllers/authStrategies/china.authStrategy.ts:1:8 - error TS1259: Module '"/Users/guamis/node_modules/bluelinky/node_modules/@types/got/index"' can only be default-imported using the 'esModuleInterop' flag 1 import got from 'got'; node_modules/@types/got/index.d.ts:25:1 src/controllers/authStrategies/chinese.legacyAuth.strategy.ts:1:8 - error TS1259: Module '"/Users/guamis/node_modules/bluelinky/node_modules/@types/got/index"' can only be default-imported using the 'esModuleInterop' flag 1 import got from 'got'; node_modules/@types/got/index.d.ts:25:1 src/controllers/authStrategies/chinese.legacyAuth.strategy.ts:5:8 - error TS2613: Module '"url"' has no default export. Did you mean to use 'import { Url } from "url"' instead? 5 import Url from 'url'; src/controllers/authStrategies/european.brandAuth.strategy.ts:1:8 - error TS1259: Module '"/Users/guamis/node_modules/bluelinky/node_modules/@types/got/index"' can only be default-imported using the 'esModuleInterop' flag 1 import got from 'got'; node_modules/@types/got/index.d.ts:25:1 src/controllers/authStrategies/european.brandAuth.strategy.ts:5:8 - error TS2613: Module '"url"' has no default export. Did you mean to use 'import { Url } from "url"' instead? 5 import Url, { URLSearchParams } from 'url'; src/controllers/authStrategies/european.legacyAuth.strategy.ts:1:8 - error TS1259: Module '"/Users/guamis/node_modules/bluelinky/node_modules/@types/got/index"' can only be default-imported using the 'esModuleInterop' flag 1 import got from 'got'; node_modules/@types/got/index.d.ts:25:1 src/controllers/authStrategies/european.legacyAuth.strategy.ts:5:8 - error TS2613: Module '"url"' has no default export. Did you mean to use 'import { Url } from "url"' instead? 5 import Url from 'url'; src/controllers/canadian.controller.ts:1:8 - error TS1259: Module '"/Users/guamis/node_modules/bluelinky/node_modules/@types/got/index"' can only be default-imported using the 'esModuleInterop' flag 1 import got from 'got'; node_modules/@types/got/index.d.ts:25:1 src/controllers/chinese.controller.ts:7:8 - error TS1259: Module '"/Users/guamis/node_modules/bluelinky/node_modules/@types/got/index"' can only be default-imported using the 'esModuleInterop' flag 7 import got, { GotInstance, GotJSONFn } from 'got'; node_modules/@types/got/index.d.ts:25:1 src/controllers/european.controller.ts:9:8 - error TS1259: Module '"/Users/guamis/node_modules/bluelinky/node_modules/@types/got/index"' can only be default-imported using the 'esModuleInterop' flag 9 import got, { GotInstance, GotJSONFn } from 'got'; node_modules/@types/got/index.d.ts:25:1 src/vehicles/american.vehicle.ts:1:8 - error TS1259: Module '"/Users/guamis/node_modules/bluelinky/node_modules/@types/got/index"' can only be default-imported using the 'esModuleInterop' flag 1 import got from 'got'; node_modules/@types/got/index.d.ts:25:1 src/vehicles/australia.vehicle.ts:26:8 - error TS1259: Module '"/Users/guamis/node_modules/bluelinky/node_modules/@types/got/index"' can only be default-imported using the 'esModuleInterop' flag 26 import got from 'got'; node_modules/@types/got/index.d.ts:25:1 src/vehicles/canadian.vehicle.ts:1:8 - error TS1259: Module '"/Users/guamis/node_modules/bluelinky/node_modules/@types/got/index"' can only be default-imported using the 'esModuleInterop' flag 1 import got from 'got'; node_modules/@types/got/index.d.ts:25:1 src/vehicles/chinese.vehicle.ts:36:8 - error TS1259: Module '"/Users/guamis/node_modules/bluelinky/node_modules/@types/got/index"' can only be default-imported using the 'esModuleInterop' flag 36 import got from 'got'; node_modules/@types/got/index.d.ts:25:1 src/vehicles/european.vehicle.ts:36:8 - error TS1259: Module '"/Users/guamis/node_modules/bluelinky/node_modules/@types/got/index"' can only be default-imported using the 'esModuleInterop' flag 36 import got from 'got'; node_modules/@types/got/index.d.ts:25:1 Found 21 errors in 17 files. Errors Files Any thoughts on how I can fix the Status fetch error SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse error? |
if you can't get a status from the debug test. your app will not work. |
The odometer calls looks the way you mentioned and I wouldn't know how to start fixing bluelinky. |
I got my status to work in debug.ts and the plug-in. Just look at the endpoint in the error stack . If you see // then it's got a typo . It should be only one / . The only comment i can say is that there is not implementation of the raw status cases . |
Would you share the Homebridge-Bluelink plugin folder and Bluelinky files with the edits you made? Thank you! |
I realized that I was skipping a big important step (npm run build) and I want to thank you for being patient and provide a solution to our problem, I am truly grateful for all your help. Kind regards, |
@carlosgamezvillegas any luck ? |
yes, I don’t have the error anymore. I should have mentioned this in my last message. Everything is working again. Thank you! |
Describe the bug
A clear and concise description of what the bug is and how to reproduce it.
Since yesterday I started getting this error after I tried to use Bluelinky:
Status fetch error SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse ()
at W. (/usr/local/lib/node_modules/homebridge-hyundai-bluelink/node_modules/bluelinky/dist/index.js:17:12462)
at Generator.next ()
at s (/usr/local/lib/node_modules/homebridge-hyundai-bluelink/node_modules/bluelinky/dist/index.js:17:85)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
This happened out of nowhere because I have not made any changes
Usefull info(please complete the following information):
Additional context
I am using node 16 since I cannot update it, if I use Node 20 I get the following error:
Client Error GotError [RequestError]: write EPROTO C07AE0ED01000000:error:0A000152:SSL routines:final_renegotiate:unsafe legacy renegotiation disabled:../deps/openssl/openssl/ssl/statem/extensions.c:922:
code: 'EPROTO',
host: 'api.telematics.hyundaiusa.com',
hostname: 'api.telematics.hyundaiusa.com',
method: 'POST',
path: '/v2/ac/oauth/token',
socketPath: undefined,
protocol: 'https:',
url: 'https://api.telematics.hyundaiusa.com/v2/ac/oauth/token',
gotOptions: {
path: '/v2/ac/oauth/token',
protocol: 'https:',
slashes: true,
auth: null,
host: 'api.telematics.hyundaiusa.com',
port: null,
hostname: 'api.telematics.hyundaiusa.com',
hash: null,
search: null,
query: null,
pathname: '/v2/ac/oauth/token',
href: 'https://api.telematics.hyundaiusa.com/v2/ac/oauth/token',
retry: {
retries: [Function (anonymous)],
methods: [Set],
statusCodes: [Set],
errorCodes: [Set]
},
headers: {
'user-agent': 'PostmanRuntime/7.26.10',
client_id: 'm66129Bb-em93-SPAHYN-bZ91-am4540zp19920',
client_secret: 'v558o935-6nne-423i-baa8',
accept: 'application/json',
'accept-encoding': 'gzip, deflate',
'content-type': 'application/json',
'content-length': 68
},
hooks: {
beforeRequest: [],
beforeRedirect: [],
beforeRetry: [],
afterResponse: [],
beforeError: [],
init: []
},
decompress: true,
throwHttpErrors: true,
followRedirect: true,
stream: false,
form: false,
json: true,
cache: false,
useElectronNet: false,
method: 'POST',
and if I use node 21 with bluelinky 8.3.1 I get the following error:
ReferenceError: ReadableStream is not defined
at Object. (/usr/local/lib/node_modules/homebridge-hyundai-bluelink/node_modules/undici/lib/web/fetch/response.js:530:3)
at Module._compile (node:internal/modules/cjs/loader:1198:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
at Module.load (node:internal/modules/cjs/loader:1076:32)
at Function.Module._load (node:internal/modules/cjs/loader:911:12)
at Module.require (node:internal/modules/cjs/loader:1100:19)
at require (node:internal/modules/cjs/helpers:119:18)
at Object. (/usr/local/lib/node_modules/homebridge-hyundai-bluelink/node_modules/undici/lib/web/fetch/index.js:11:5)
at Module._compile (node:internal/modules/cjs/loader:1198:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
I would appreciate the help since I am out of workarounds.
Thanks
The text was updated successfully, but these errors were encountered: