Skip to content

Conversation

kinyoklion
Copy link
Member

@kinyoklion kinyoklion commented Mar 13, 2023

Nanoid was dependent on Buffers which is not standard and caused some problems with some edge providers. It seemed better to remove it now.

Also originally I had switched from uuid to nanoid for a similar compatibility reason. Now that dependency is removed from common code and pushed to the platform. So the platform can use the UUID implementation that works for it.

For edge environments I hope most of them support crypto.randomUUID. Assuming that the securecontext requirement is not applicable, because it is server side, or that it doesn't interfere with their operation.

This change should generally make it easier to support uuidv4 generation without requiring a polyfill in the shared packages.

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #192052: Look at removing nanoid dependency..

}

uuidv4() {
return randomUUID();
Copy link
Member Author

Choose a reason for hiding this comment

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

Our targeted versions of node should have this built-in. Which is better than a dependency. But it isn't something we can promise will be in all server SDKs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Less code = more better

@@ -103,7 +102,7 @@ export default class DiagnosticsManager {
this.startTime = Date.now();
this.dataSinceDate = this.startTime;
this.id = {
diagnosticId: nanoid(),
diagnosticId: platform.crypto.uuidv4(),
Copy link
Member Author

Choose a reason for hiding this comment

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

Now we use the platform provided uuidv4. (Platform here being our implementation of the platform. Like server-node,)

@kinyoklion kinyoklion marked this pull request as ready for review March 13, 2023 22:26
@kinyoklion kinyoklion merged commit 282a3fe into main Mar 13, 2023
@kinyoklion kinyoklion deleted the rlamb/sc-192052/remove-nanoid branch March 13, 2023 23:03
This was referenced Mar 15, 2023
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.

2 participants