File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -443,10 +443,15 @@ async function getCacheRestoreKey(
443443 * @returns A short SHA-256 hash (first 16 characters) of the components
444444 */
445445function createCacheKeyHash ( components : Record < string , any > ) : string {
446- const componentsJson = JSON . stringify (
447- components ,
448- Object . keys ( components ) . sort ( ) ,
449- ) ;
446+ // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
447+ //
448+ // "Properties are visited using the same algorithm as Object.keys(), which
449+ // has a well-defined order and is stable across implementations. For example,
450+ // JSON.stringify on the same object will always produce the same string, and
451+ // JSON.parse(JSON.stringify(obj)) would produce an object with the same key
452+ // ordering as the original (assuming the object is completely
453+ // JSON-serializable)."
454+ const componentsJson = JSON . stringify ( components ) ;
450455 return crypto
451456 . createHash ( "sha256" )
452457 . update ( componentsJson )
You can’t perform that action at this time.
0 commit comments