Revadike / epicgames-freebies-claimer

Claim available free game promotions from the Epic Games Store.
MIT License
2.23k stars 361 forks source link

SyntaxError: Unexpected end of JSON input #152

Closed ffuubarbuzz closed 2 years ago

ffuubarbuzz commented 2 years ago

Expected Behavior

Container keeps running and not crashing

Actual Behavior

Container crashed with the following log:

undefined:1
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /app/node_modules/check-update-github/lib/latest-version.js:19:19
    at /app/node_modules/got/index.js:174:5
    at BufferStream.<anonymous> (/app/node_modules/read-all-stream/index.js:52:3)
    at BufferStream.emit (node:events:402:35)
    at finishMaybe (/app/node_modules/readable-stream/lib/_stream_writable.js:630:14)
    at endWritable (/app/node_modules/readable-stream/lib/_stream_writable.js:638:3)
    at BufferStream.Writable.end (/app/node_modules/readable-stream/lib/_stream_writable.js:594:41)
    at IncomingMessage.onend (node:internal/streams/readable:693:10)
    at Object.onceWrapper (node:events:509:28)

Steps to Reproduce the Problem

Just had a container running in the background

Specifications

Probably it's worth wrapping update checker call with try/catch

Revadike commented 2 years ago

It must have failed requesting https://raw.githubusercontent.com/Revadike/epicgames-freebies-claimer/master/package.json Maybe it's blocked on your end. You're right, we should do some error handling.

ffuubarbuzz commented 2 years ago

The container was working fine (btw reporting newer version as latest docker is still 1.5.5) for quite a while, and after failure and restarting version got checked without problems. Might be github or network hiccup, but anyway version check failure shouldn't be critical for the container.

jackblk commented 2 years ago

The container was working fine (btw reporting newer version as latest docker is still 1.5.5) for quite a while, and after failure and restarting version got checked without problems. Might be github or network hiccup, but anyway version check failure shouldn't be critical for the container.

The latest version in docker image will follow the latest release version, I don't maintain release candidate version.

I think we can avoid this, instead of using package.json from master branch, we use this api: https://api.github.com/repos/Revadike/epicgames-freebies-claimer/releases

This gives us the latest release version in tag_name, which is better I think.

Either this, or we need to maintain a develop branch, only merge to master when we release a new version.

jackblk commented 2 years ago

Been working on this using github release api, I will create a PR soon. It will check through the actual release, so if the master branch is still being worked on but not released yet, it will not warn anymore.

We can remove check-update-github dependency. One less dependency :).

Revadike commented 2 years ago

It's not much different, though. One looks at the GitHub Release API and the package looks at the GitHub Repo API and checks the package.json file. So, I'm not so sure what we gain from it.

jackblk commented 2 years ago

@Revadike

Current way: using package.json in master branch: v1.5.6 (this is still not released yet, we are still working on it). It is still v1.5.5 in Release: https://github.com/Revadike/epicgames-freebies-claimer/releases. If user uses the latest Docker image right now, it is v1.5.5 and there will be a warning.

If we use Github Release API then the latest release will be v1.5.5 -> correct one

Revadike commented 2 years ago

Fair point. Should I wait for this before releasing v1.5.6?

jackblk commented 2 years ago

I will push a PR soon, please wait 😄