Skip to content

Commit

Permalink
[Asset graph] Hash the key used for layout cache (#16989)
Browse files Browse the repository at this point in the history
## Summary & Motivation
Hashing the key


## How I Tested These Changes
Loaded the asset graph and saw it working
  • Loading branch information
salazarm authored and yuhan committed Oct 3, 2023
1 parent df4fdae commit 0a26ec4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion js_modules/dagster-ui/packages/ui-core/src/app/Util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@ export function indexedDBAsyncMemoize<T, R, U extends (arg: T, ...rest: any[]) =
maxCount: 50,
});
const ret = (async (arg: T, ...rest: any[]) => {
const hashKey = hashFn ? hashFn(arg, ...rest) : arg;
const hash = hashFn ? hashFn(arg, ...rest) : arg;

const encoder = new TextEncoder();
const data = encoder.encode(hash.toString());
const hashBuffer = await crypto.subtle.digest('SHA-1', data);
const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
const hashKey = hashArray.map((b) => b.toString(16).padStart(2, '0')).join(''); // convert bytes to hex string

return new Promise<R>(async (resolve) => {
if (await lru.has(hashKey)) {
Expand Down

0 comments on commit 0a26ec4

Please sign in to comment.