Skip to content
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

HTTP Errors when creating some pins #6

Closed
boehs opened this issue Jul 16, 2024 — with Linear · 5 comments
Closed

HTTP Errors when creating some pins #6

boehs opened this issue Jul 16, 2024 — with Linear · 5 comments

Comments

Copy link
Member

boehs commented Jul 16, 2024

Causes HTTP error when creating new pins. Both for the metadata endpoint and the submission endpoint

{
    "success": false,
    "message": "Cannot convert object to primitive value",
    "data": null,
    "status": "Internal Server Error"
}

For submission, we see

  "logs": [
    {
      "message": [
        "\u001b[2m241ms: begin\u001b[22m"
      ],
      "level": "log",
      "timestamp": 1721135008152
    },
    {
      "message": [
        "\u001b[2m268ms: select * from \"entities\" where \"url\" = $1\u001b[22m"
      ],
      "level": "log",
      "timestamp": 1721135008420
    },
    {
      "message": [
        "\u001b[2m132ms: rollback\u001b[22m"
      ],
      "level": "log",
      "timestamp": 1721135008645
    },
    {
      "message": [
        "TypeError: Cannot convert object to primitive value"
      ],
      "level": "log",
      "timestamp": 1721135008645
    }

For metadata, we see

    {
      "message": [
        "TypeError: Cannot convert object to primitive value"
      ],
      "level": "log",
      "timestamp": 1721135192413
    }
@boehs boehs added the bug label Jul 16, 2024 — with Linear
Copy link

linear bot commented Jul 16, 2024

@boehs
Copy link
Member Author

boehs commented Jul 16, 2024

might not be my error
image

@boehs
Copy link
Member Author

boehs commented Jul 16, 2024

image
error is inside the psl package

@boehs
Copy link
Member Author

boehs commented Jul 16, 2024

Postmortem

The cause

arises from the deprecated punycode module (lupomontero/psl#323 lupomontero/psl#315) which has caused issues before.

image

see this thread in cf discord for same error being caused by punycode

image

experienced issues in aws-sdk related to this asw, see cfdsc and the following issues that are all intrinsically related, which is why we switched to aws4fetch

The solution

We will follow how others did, see

issue will be closed when fix is applied.

@boehs
Copy link
Member Author

boehs commented Jul 16, 2024

Lessons

punycode causes issues on cf runtime. Three different runtimes we use

  • production @ cf import.meta.env.MODE == "development"
  • node.js based dev import.meta.env.MODE == "production"

the third is the problem child: miniflare with workerd. To use miniflare, you build the application the same way but avoid the deployment step. This means env is set to production, but this isn't production, causing

  1. Endpoints to be incorrectly mapped to prod instead of localhost
  2. Promise races due to a DB cache which doesn't work in workerd (maybe only with hyperdrive?)
image
  1. I believe there are currently permission issues with the connection string for the local db replica in this mode. I have not diagnosed the causation.

Short term solution was to create a mode constant that we can just edit and then REMEMBER TO REMOVE WHEN COMMITTING (bedba32). long term solution will be harder: nksaraf/vinxi#304, somehow we need full builds to still happen with mode set to development

@boehs boehs closed this as completed in c778d12 Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant