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

fix #3030 and run relateive test in edge-runtime #3036

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

promer94
Copy link
Collaborator

@promer94 promer94 commented Nov 5, 2024

This pr intends to fix the inconsistent behavoir of swr's hash in edge-runtime dev mode.

The reason for this problem is because we're using node.js to simulate the edge-runtime for local development

The global Array and Object of edge-runtime are injected from node.js and the JS engine does not use global Array/Object constructor while building an array/object literal.

Then in dev mode

[].constructor !== Array.constructor
{}.construrtor !== Object.contructor

So we need find alternative to determine whether a key is an array or a plain object

Copy link

codesandbox-ci bot commented Nov 5, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link

socket-security bot commented Nov 5, 2024

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher

View full report↗︎

@promer94 promer94 requested a review from koba04 November 7, 2024 07:03
src/_internal/utils/hash.ts Outdated Show resolved Hide resolved
Copy link
Member

@huozhi huozhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a PR description and some comments about the change in hash? It's important for others to understand the approach and grab the context when they read the code later unless directly by reading the code

package.json Outdated Show resolved Hide resolved
src/_internal/utils/hash.ts Outdated Show resolved Hide resolved
src/_internal/utils/hash.ts Show resolved Hide resolved
@@ -167,7 +167,8 @@
"trailingComma": "none"
},
"dependencies": {
"@edge-runtime/jest-environment": "^3.0.4",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be dev dependency

"dequal": "^2.0.3",
"use-sync-external-store": "^1.2.0"
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep the trailign line break for each file?

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

Successfully merging this pull request may close these issues.

3 participants