ghostfolio / ghostfolio

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
https://Ghostfol.io
GNU Affero General Public License v3.0
3.79k stars 355 forks source link

[BUG] Invalid number exception in computeSnapshot method #3456

Open qrees opened 3 weeks ago

qrees commented 3 weeks ago

Bug Description

Ghostfolio hard crashes on Portfolio -> Analysis page. Whole application has to be restarted.

To Reproduce

  1. Open Portfolio -> Analysis page
  2. Crash with exception:
    
    [Nest] 122  - 06/04/2024, 1:07:59 PM   ERROR [ExceptionsHandler] [big.js] Invalid number
    Error: [big.js] Invalid number
    at parse (/ghostfolio/apps/api/node_modules/big.js/big.js:142:13)
    at new Big (/ghostfolio/apps/api/node_modules/big.js/big.js:109:9)
    at P.times.P.mul (/ghostfolio/apps/api/node_modules/big.js/big.js:843:17)
    at TWRPortfolioCalculator.computeSnapshot (/ghostfolio/apps/api/main.js:1:421105)
    at async TWRPortfolioCalculator.initialize (/ghostfolio/apps/api/main.js:1:431685)
    at async TWRPortfolioCalculator.getSnapshot (/ghostfolio/apps/api/main.js:1:429071)
    at async PortfolioService.getDetails (/ghostfolio/apps/api/main.js:1:453313)
    at async PortfolioController.getHoldings (/ghostfolio/apps/api/main.js:1:480128)
    /ghostfolio/apps/api/node_modules/big.js/big.js:142
      throw Error(INVALID + 'number');
            ^

Error: [big.js] Invalid number at parse (/ghostfolio/apps/api/node_modules/big.js/big.js:142:13) at new Big (/ghostfolio/apps/api/node_modules/big.js/big.js:109:9) at P.times.P.mul (/ghostfolio/apps/api/node_modules/big.js/big.js:843:17) at TWRPortfolioCalculator.computeSnapshot (/ghostfolio/apps/api/main.js:1:421105) at async TWRPortfolioCalculator.initialize (/ghostfolio/apps/api/main.js:1:431311)

Node.js v18.20.3


**Expected behavior**

No crash

**Screenshots**

Not gui related.

**Logs**

More logs:

Please consider completing the survey at https://bit.ly/yahoo-finance-api-feedback if you haven't already; for more info see https://github.com/gadicc/node-yahoo-finance2/issues/764#issuecomment-2056623851. Fetching crumb and cookies from https://finance.yahoo.com/quote/AAPL... fetch https://guce.yahoo.com/consent?brandType=nonEu&gcrumb=RHd0rGI&done=https%3A%2F%2Ffinance.yahoo.com%2Fquote%2FAAPL fetch https://consent.yahoo.com/v2/collectConsent?sessionId=3_cc-session_4b4b7589-2ac0-4017-9b01-68ce0eb504c0 fetch https://consent.yahoo.com/v2/collectConsent?sessionId=3_cc-session_4b4b7589-2ac0-4017-9b01-68ce0eb504c0 fetch https://guce.yahoo.com/copyConsent?sessionId=3_cc-session_4b4b7589-2ac0-4017-9b01-68ce0eb504c0&lang=fr-FR Fetching crumb and cookies from https://finance.yahoo.com/quote/AAPL?guccounter=1... We expected a redirect to guce.yahoo.com, but got https://finance.yahoo.com/quote/AAPL/ We'll try to continue anyway - you can safely ignore this if the request succeeds Success. Cookie expires on Infinity fetch https://query1.finance.yahoo.com/v1/test/getcrumb New crumb: 8lNVrlFk10e [Nest] 122 - 06/04/2024, 1:07:59 PM ERROR [ExceptionsHandler] [big.js] Invalid number Error: [big.js] Invalid number at parse (/ghostfolio/apps/api/node_modules/big.js/big.js:142:13) at new Big (/ghostfolio/apps/api/node_modules/big.js/big.js:109:9) at P.times.P.mul (/ghostfolio/apps/api/node_modules/big.js/big.js:843:17) at TWRPortfolioCalculator.computeSnapshot (/ghostfolio/apps/api/main.js:1:421105) at async TWRPortfolioCalculator.initialize (/ghostfolio/apps/api/main.js:1:431685) at async TWRPortfolioCalculator.getSnapshot (/ghostfolio/apps/api/main.js:1:429071) at async PortfolioService.getDetails (/ghostfolio/apps/api/main.js:1:453313) at async PortfolioController.getHoldings (/ghostfolio/apps/api/main.js:1:480128) /ghostfolio/apps/api/node_modules/big.js/big.js:142 throw Error(INVALID + 'number'); ^

Error: [big.js] Invalid number at parse (/ghostfolio/apps/api/node_modules/big.js/big.js:142:13) at new Big (/ghostfolio/apps/api/node_modules/big.js/big.js:109:9) at P.times.P.mul (/ghostfolio/apps/api/node_modules/big.js/big.js:843:17) at TWRPortfolioCalculator.computeSnapshot (/ghostfolio/apps/api/main.js:1:421105) at async TWRPortfolioCalculator.initialize (/ghostfolio/apps/api/main.js:1:431311)

Node.js v18.20.3



**Environment**

<!-- Please complete the following information -->

- Ghostfolio Version 2.84.0
- Self-hosted
- Experimental Features disabled
- Chrome
- Ubuntu