@@ -16,7 +16,6 @@ export default eventHandler(async (event) => {
1616 const { test } = useRuntimeConfig ( event ) ;
1717 const workflowsBucket = useWorkflowsBucket ( event ) ;
1818 const pullRequestNumbersBucket = usePullRequestNumbersBucket ( event ) ;
19- const cursorBucket = useCursorsBucket ( event ) ;
2019
2120 const workflowHandler : HandlerFunction < "workflow_run" , unknown > = async ( {
2221 payload,
@@ -42,9 +41,20 @@ export default eventHandler(async (event) => {
4241 full_name : payload . workflow_run . head_repository . full_name ,
4342 ref : payload . workflow_run . head_branch ,
4443 } ;
45- const prDataHash = hash ( prData ) ;
46- const isPullRequest = await pullRequestNumbersBucket . hasItem ( prDataHash ) ;
47- const prNumber = await pullRequestNumbersBucket . getItem ( prDataHash ) ;
44+ // new: using the new key to avoid collision
45+ const prKey = `${ prData . full_name } :${ prData . ref } ` ;
46+ const isNewPullRequest = await pullRequestNumbersBucket . hasItem ( prKey ) ;
47+
48+ // old: the old of hashing the prData started to hit collision, so we need to use the new one (e.g. https://github.com/element-plus/element-plus/actions/runs/12351113750/job/34465376908)
49+ const oldPrDataHash = hash ( prData ) ;
50+ const isOldPullRequest = await pullRequestNumbersBucket . hasItem (
51+ oldPrDataHash ,
52+ ) ;
53+
54+ const isPullRequest = isNewPullRequest || isOldPullRequest ;
55+ const prNumber = await pullRequestNumbersBucket . getItem (
56+ isNewPullRequest ? prKey : oldPrDataHash ,
57+ ) ;
4858
4959 const data : WorkflowData = {
5060 owner,
@@ -64,15 +74,16 @@ export default eventHandler(async (event) => {
6474 const pullRequestHandler : HandlerFunction < "pull_request" , unknown > = async ( {
6575 payload,
6676 } ) => {
67- const [ owner , repo ] = payload . repository . full_name . split ( "/" ) ;
6877 // TODO: functions that generate these kinda keys
6978 const key : PullRequestData = {
7079 full_name : payload . pull_request . head . repo ?. full_name ! ,
7180 ref : payload . pull_request . head . ref ,
7281 } ;
73- const prDataHash = hash ( key ) ;
7482 if ( prMarkEvents . includes ( payload . action ) ) {
75- await pullRequestNumbersBucket . setItem ( prDataHash , payload . number ) ;
83+ await pullRequestNumbersBucket . setItem (
84+ `${ key . full_name } :${ key . ref } ` ,
85+ payload . number ,
86+ ) ;
7687 }
7788 } ;
7889
0 commit comments