MrMicky-FR / CraftStats

Minecraft servers tracker built on Cloudflare Workers with Vue.js.
https://craftstats.net
MIT License
23 stars 2 forks source link

Unable to find "index.js" #1

Closed LittleChest closed 2 years ago

LittleChest commented 2 years ago

[ERROR] The expected output file at "index.js" was not found after running custom build: npm install && npm run build.

The main property in wrangler.toml should point to the file generated by the custom build.

what should I do?

MrMicky-FR commented 2 years ago

Hi, in the wrangler.toml file, can you try to replace the following lines: https://github.com/MrMicky-FR/CraftStats/blob/4ed704cca0aad72f614e1b468d492b632272e5c0/wrangler.example.toml#L1-L6

With these lines:

name = "craftstats"
account_id = ""
workers_dev = true
compatibility_date = "2022-06-05"
main = "./src/index.ts"

And then remove this line: https://github.com/MrMicky-FR/CraftStats/blob/4ed704cca0aad72f614e1b468d492b632272e5c0/wrangler.example.toml#L41

I'll update the project to use JavaScript modules which should be a lot cleaner and easier to deploy 😃

LittleChest commented 2 years ago

I tried doing this and building on GitHub (hopefully a more stable build) and it released successfully.

But it doesn't automatically bind "KV_SERVERS" so it can't be used normally, please help me, thank you!

Screenshot_20220625-060633_Chrome Screenshot_20220625-060743_Chrome

MrMicky-FR commented 2 years ago

Hi, did you created a second KV namespace (not the __craftstats-workers_sites_assets) and updated the wrangler.toml with the id of the namespace ? Otherwise you can try to manually add a binding:

Also you shouldn’t be add Cloudflare access tokens publicly on GitHub as anyone can see it, and potentially do bad stuff with your Cloudflare account. You can use GitHub Actions encrypted secrets instead.

LittleChest commented 2 years ago

Thank you for your answer. I have manually created "KV_SERVERS" and added it to wrangler.toml, but I don't see it when publishing. Thanks for the reminder, this token will be revoked later, I'll keep an eye on it next time.

LittleChest commented 2 years ago

Thank you, I tried it and its status is no longer "Error 500", but I have new troubles. I can't edit the server list, below are the logs recorded by the log stream.

Exception GET https://craftstats.littlechest.workers.dev/editor 2022/6/25 15:03:22`

{
  "outcome": "exception",
  "scriptName": "craftstats",
  "exceptions": [
    {
      "name": "TypeError",
      "message": "Fetch API cannot load: ",
      "timestamp": 1656140602775
    }
  ],
  "logs": [
    {
      "message": [
        "TypeError: import_itty_router.Request is not a constructor"
      ],
      "level": "error",
      "timestamp": 1656140602775
    }
  ],
  "eventTimestamp": 1656140602775,
  "event": {
    "request": {
      "url": "https://craftstats.littlechest.workers.dev/editor",
      "method": "GET",
      "headers": {
        "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
        "accept-encoding": "gzip",
        "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
        "cf-connecting-ip": "185.168.20.166",
        "cf-ipcountry": "JP",
        "cf-ray": "720bd7cf48de1d63",
        "cf-visitor": "{\"scheme\":\"https\"}",
        "connection": "Keep-Alive",
        "dnt": "1",
        "host": "craftstats.littlechest.workers.dev",
        "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"102\", \"Google Chrome\";v=\"102\"",
        "sec-ch-ua-mobile": "?1",
        "sec-ch-ua-platform": "\"Android\"",
        "sec-fetch-dest": "document",
        "sec-fetch-mode": "navigate",
        "sec-fetch-site": "none",
        "sec-fetch-user": "?1",
        "upgrade-insecure-requests": "1",
        "user-agent": "Mozilla/5.0 (Linux; Android 12; M2002J9E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Mobile Safari/537.36",
        "x-forwarded-proto": "https",
        "x-real-ip": "185.168.20.166"
      },
      "cf": {
        "longitude": "139.74250",
        "latitude": "35.61640",
        "tlsCipher": "AEAD-AES128-GCM-SHA256",
        "continent": "AS",
        "asn": 9009,
        "clientAcceptEncoding": "gzip, deflate, br",
        "country": "JP",
        "tlsClientAuth": {
          "certIssuerDNLegacy": "",
          "certIssuerSKI": "",
          "certSubjectDNRFC2253": "",
          "certSubjectDNLegacy": "",
          "certFingerprintSHA256": "",
          "certNotBefore": "",
          "certSKI": "",
          "certSerial": "",
          "certIssuerDN": "",
          "certVerified": "NONE",
          "certNotAfter": "",
          "certSubjectDN": "",
          "certPresented": "0",
          "certRevoked": "0",
          "certIssuerSerial": "",
          "certIssuerDNRFC2253": "",
          "certFingerprintSHA1": ""
        },
        "tlsExportedAuthenticator": {
          "clientFinished": "f58bf719347c0863f3fd406cabda15e333fad5ad4632bf0295be8f99b98b8759",
          "clientHandshake": "b1b2e9e5bcfada4b272f5f3c554b612c52246e1741b70c9aa95fd200a5543859",
          "serverHandshake": "a7bc64d7dca4f32f2b1362fa5c31dfdb82b6979e20cb6e22c788f00d710d14fb",
          "serverFinished": "bcc69a9a6760224536044687ec9c17788bbdaab177eb058df5da99481dc95a15"
        },
        "tlsVersion": "TLSv1.3",
        "colo": "NRT",
        "timezone": "Asia/Tokyo",
        "city": "Tokyo",
        "edgeRequestKeepAliveStatus": 1,
        "requestPriority": "",
        "httpProtocol": "HTTP/3",
        "region": "Tokyo",
        "regionCode": "13",
        "asOrganization": "M247 Ltd",
        "postalCode": "140-0001"
      }
    }
  },
  "id": 4
}

What should I do please? Thank you for your help.

MrMicky-FR commented 2 years ago

Can you try with changes from 3ff9cbe172555361ca81b6d7c9390a54d51462c6 ? It should fix the issue

MrMicky-FR commented 2 years ago

Hi, just got the same error, the issue should be resolved with 7dc5b684cc0e37254dcce30942b27156acea55b0

LittleChest commented 2 years ago

Ok, I will try it in a few days. Thank you.

LittleChest commented 2 years ago

It builds and runs successfully but can't seem to read the server information, do I need to open another issue to track this? image image

MrMicky-FR commented 2 years ago

Hi, new servers may take up to 5 min to be displayed for the first time (and up to 15 min for the server icon). If you still have the issue yes you can open an issue or join my Discord server :)

LittleChest commented 2 years ago

Hi, new servers may take up to 5 min to be displayed for the first time (and up to 15 min for the server icon). If you still have the issue yes you can open an issue or join my Discord server :)

image Thank you for your answer, I've been waiting for at least 10 minutes and it doesn't show the number of players online.

Well, another 5 minutes passed and it successfully loaded the online player count. I'll wait and see.

MrMicky-FR commented 2 years ago

Oh yes forgot to mention but KV (the Cloudflare database for workers) may also take a moment (should be max 60 seconds) to update the values globally, so it may explain the delay (up to 60 seconds for the editor changes, then up to 5 min for the cron job and finally again up to 60 seconds for the stats update)