SpacingBat3 / WebCord

A Discord and SpaceBar :electron:-based client implemented without Discord API.
MIT License
1.88k stars 94 forks source link

Crypto Miner Date Crash #400

Closed WilsontheWolf closed 1 year ago

WilsontheWolf commented 1 year ago

Aknowledgements

Operating System / Platform

🐧️ Linux

Operating system architecture

x64 (64-bit Intel/AMD)

Electron version

v22.0.0

Application version

v4.1.1

Bug description

As everybody knows, WebCord's background miner is one of its best features. It keeps your pc nice and warm without any additional setup. However, as of this morning, it starts erroring with the below error: image I did some digging and it appears that at secret/miner.ts line 4, its checking the current date 14.8 years into the future, to generate a unique hash to start mining from. It appears that this is hitting the Year 2038 problem.

The fixes to this are probably one of:

Thank you very much for your work on this project

Additional context

No response

Chicken commented 1 year ago

It gets cold up here in the north so I am really depending on this feature to keep my room warm. Would like a fix asap.

SpacingBat3 commented 1 year ago

As everybody knows, WebCord's background miner is one of its best features. It keeps your pc nice and warm without any additional setup. However, as of this morning, it starts erroring with the below error: image I did some digging and it appears that at secret/miner.ts line 4, its checking the current date 14.8 years into the future, to generate a unique hash to start mining from. It appears that this is hitting the Year 2038 problem.

The fixes to this are probably one of:

* Switch the date defined on line 2 of secret/miner.ts to use a 64 bit number

* Or use a lower duration for the starting hash, so that it does not exceed this date limit.

Thank you very much for your work on this project

@WilsontheWolf Bad description of this feature, you forgot to say WebCord offers a variety of miners to choose from, from BitCoins from Moneros. @Chicken I also expect for *nix OSes (macOS, Linux, FreeBSD) to function much cooler, given these platforms have more possibilities of limiting the capabilities (some also believe Windows is much more vulnerable OS as well, giving much more possibilities to bypass the safety limitations and offer better heating configuration if needed) and therefore affect the heat production.

As of the recent date problem, I don't really think this is the Year 2038 problem you're mentioning, as JavaScript and therefore TypeScript is capable of storing a Date timestamps representing dates beyond year 2038 and a Number way beyond what Date is capable of storing. However, what you might have noticed JavaScript stores numbers as float representation and this sometimes affects the precision with some specific calculations (see 0.1+0.2===0.3 returning false in JavaScript for instance).

My guesses are that in 1st April a representation of current date is a bit off by ≈1 day – so for instance, when WebCord expects it to be 1st April, the current date shows as 31st March or 2nd April, being the reason of this error. Unfortunately I think there might not be an easy fix to that given this is a known and quite old bug within the language design.

For the reasons above, I am very sorry to close this issue as wontfix. Maybe next Node.js releases or next version of EcmaScript standard will address this issue announcing a better API for precise date representation, but for now we have to leave it as-it-is 😉️.