-
Notifications
You must be signed in to change notification settings - Fork 7
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
Use JSDOM alternative for deploying to Vercel #95
base: main
Are you sure you want to change the base?
Conversation
database/connect.ts
Outdated
@@ -15,6 +14,7 @@ declare module globalThis { | |||
function connectOneTimeToDatabase() { | |||
if (!globalThis.postgresSqlClient) { | |||
globalThis.postgresSqlClient = postgres({ | |||
ssl: !!process.env.POSTGRES_URL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use Boolean()
here for expressiveness?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
types/index.d.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I guess the contents of
types/base.d.ts
could be merged into this file? - the filename can be
jsdom-napi-rs-canvas.d.ts
- the file can be in the root of the project - until we have a more types
but not a big deal to make this super polished yet, we're not sure if we are staying with Vercel for this project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: @types/jsdom@21.1.1, canvas@2.11.2, jsdom@22.1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestions applied
Edit: The link below has problems, I changed it to https://vuln-examples-next-postgres-jose.vercel.app/ Seems like the Railway link ( https://vuln-examples-next-postgres-jose-production.up.railway.app ) that was in the About section doesn't currently work, so I used the Vercel link above instead ( https://vuln-examples-next-postgres-jose-7nzgag60s-josehower.vercel.app/ ) The deployed version on Fly.io ( https://security-vulnerability-examples-next-js-postgres.fly.dev/ ) has been crashing up until this point, but this may improve in the future |
The version deployed on Fly.io is not crashing currently https://security-vulnerability-examples-next-js-postgres.fly.dev/ |
@Josehower the JSDOM + DOMPurify example doesn't seem to work on Vercel currently - so maybe the approach in this PR doesn't work? |
Oh, it seems there is another deployment at https://vuln-examples-next-postgres-jose.vercel.app/ The Example 6, Solution 2 page here works fine: https://vuln-examples-next-postgres-jose.vercel.app/example-6-cross-site-scripting/solution-2 |
Handover Comment for the PR: What work has been done
What work is still open
who to take overThis can be handover by either @ProchaLu or @Eprince-hub Where to startA good place to start would be to get familiar with the changes in the PR and understand what is trying to be achieved. Get a conversation with @karlhorky to define if a PR to main is the best place to contain this deploy alternative or maybe it just needs another repo or just a branch. Other details that you know that are not captured already in the issue / PRNot really sure if this is a PR that wants to get merged to the main or have it as a backup in case fly.io doesn't work This PR is an alternative to deploy the example on serverless environments. This was created since the version on fly.io was not working due to memory issues with Next.js |
Handover TODO's
This branch has been deployed here:
https://vuln-examples-next-postgres-jose-7nzgag60s-josehower.vercel.app/
When trying to deploy to Vercel multiple issues appear when using JSDOM.
1. JSDOM makes the Serverless function exceed the maximum size
This problem was solved by using a lightweight version of JSDOM like https://www.npmjs.com/package/jsdom-light
2. JSDOM using canvas missing dependencies in serverless environments
The way we solve it this was by using a JSDOM solution that was implementing a canvas version that was compatible with serverless environments:
https://www.npmjs.com/package/jsdom-napi-rs-canvas (published from
Miggogee/jsdom
)Related Links: