[{"data":1,"prerenderedAt":442},["ShallowReactive",2],{"navigation_docs":3,"rule-content-\u002Fnitro\u002Frules\u002Fcloudflare\u002Fno-unguarded-als-enterwith":48},[4,8,12,16,20,24,28,32,36,40,44],{"title":5,"path":6,"stem":7},"CLI","\u002Fcli","1.cli",{"title":9,"path":10,"stem":11},"Nuxt","\u002Fnuxt","2.nuxt",{"title":13,"path":14,"stem":15},"Vue","\u002Fvue","3.vue",{"title":17,"path":18,"stem":19},"Vite","\u002Fvite","4.vite",{"title":21,"path":22,"stem":23},"Nitro","\u002Fnitro","5.nitro",{"title":25,"path":26,"stem":27},"TypeScript","\u002Ftypescript","6.typescript",{"title":29,"path":30,"stem":31},"shadcn","\u002Fshadcn","7.shadcn",{"title":33,"path":34,"stem":35},"Package","\u002Fpackage","8.package",{"title":37,"path":38,"stem":39},"Extending Doctor","\u002Fextending","9.extending",{"title":41,"path":42,"stem":43},"MCP","\u002Fmcp","9.mcp",{"title":45,"path":46,"stem":47},"Pinia","\u002Fpinia","9.pinia",{"id":49,"title":50,"body":51,"category":57,"description":429,"diagnosticCodes":430,"docsUrl":59,"extension":431,"fix":60,"framework":432,"meta":433,"navigation":434,"pack":61,"path":436,"recommendedReplacement":437,"ruleId":62,"seo":438,"severity":63,"source":64,"sourceUrl":65,"stem":439,"why":440,"__hash__":441},"rules\u002Fnitro\u002Frules\u002Fcloudflare\u002Fno-unguarded-als-enterwith.md","Guard AsyncLocalStorage#enterWith on Cloudflare",{"type":52,"value":53,"toc":420},"minimark",[54,66,71,109,113,150,154,164,168,194,198,203,206,310,313,416],[55,56],"rule-metadata",{"category":57,"diagnosticCodes":58,"docsUrl":59,"fix":60,"pack":61,"ruleId":62,"severity":63,"source":64,"sourceUrl":65},"runtime","NITRO0024","https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002Fruntime-apis\u002Fnodejs\u002Fasynclocalstorage\u002F","suggestion","vite-doctor\u002Fnitro","nitro\u002Fcloudflare\u002Fno-unguarded-als-enterwith","error","src\u002Frule-packs\u002Fnitro\u002Frules\u002Fno-unguarded-als-enter-with.ts","https:\u002F\u002Fgithub.com\u002Fonmax\u002Fvite-doctor\u002Fblob\u002Fmain\u002Fsrc\u002Frule-packs\u002Fnitro\u002Frules\u002Fno-unguarded-als-enter-with.ts",[67,68,70],"h2",{"id":69},"run-this-rule","Run this rule",[72,73,78],"pre",{"className":74,"code":75,"language":76,"meta":77,"style":77},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","pnpm vite-doctor . --framework nitro --rules nitro\u002Fcloudflare\u002Fno-unguarded-als-enterwith\n","bash","",[79,80,81],"code",{"__ignoreMap":77},[82,83,86,90,94,97,100,103,106],"span",{"class":84,"line":85},"line",1,[82,87,89],{"class":88},"sBMFI","pnpm",[82,91,93],{"class":92},"sfazB"," vite-doctor",[82,95,96],{"class":92}," .",[82,98,99],{"class":92}," --framework",[82,101,102],{"class":92}," nitro",[82,104,105],{"class":92}," --rules",[82,107,108],{"class":92}," nitro\u002Fcloudflare\u002Fno-unguarded-als-enterwith\n",[67,110,112],{"id":111},"why-it-matters","Why it matters",[114,115,116,117,120,121,120,124,120,127,130,131,134,135,138,139,137,142,145,146,149],"p",{},"workerd implements AsyncLocalStorage ",[79,118,119],{},"run()",", ",[79,122,123],{},"exit()",[79,125,126],{},"getStore()",[79,128,129],{},"bind()",", and ",[79,132,133],{},"snapshot()",", but ",[79,136,137],{},"enterWith()"," throws ",[79,140,141],{},"asyncLocalStorage.",[79,143,144],{}," is not implemented",", with nodejs_compat or nodejs_als enabled. Code that works in Node.js then fails the request on Cloudflare. The rule runs when Project Inventory shows a Cloudflare target for the workspace package: a wrangler config, a cloudflare Nitro preset, Cloudflare tooling dependencies such as wrangler or @cloudflare\u002Fworkers-types, a cloudflare package keyword, or ",[79,147,148],{},"cloudflare:"," imports in the file.",[67,151,153],{"id":152},"recommended-fix","Recommended fix",[114,155,156,157,160,161,163],{},"Run the work inside als.",[79,158,159],{},"run(store, callback)"," so the store is scoped to the callback. If the call has to stay for Node.js runtimes, wrap it in try\u002Fcatch and keep a fallback that does not depend on ",[79,162,137],{},".",[67,165,167],{"id":166},"useful-links","Useful links",[169,170,171,180,187],"ul",{},[172,173,174],"li",{},[175,176,179],"a",{"href":59,"rel":177},[178],"nofollow","Rule reference",[172,181,182],{},[175,183,186],{"href":184,"rel":185},"https:\u002F\u002Fnuxt.com\u002Fdocs\u002F4.x\u002Fguide\u002Fgoing-further\u002Fruntime-config",[178],"Nuxt runtime config",[172,188,189],{},[175,190,193],{"href":191,"rel":192},"https:\u002F\u002Fnitro.build\u002Fguide\u002Frouting",[178],"Nitro handlers",[67,195,197],{"id":196},"example","Example",[199,200,202],"h3",{"id":201},"scope-the-store-with-run","Scope the store with run()",[114,204,205],{},"Before",[72,207,211],{"className":208,"code":209,"language":210,"meta":77,"style":77},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","const eventStorage = new AsyncLocalStorage\u003CH3Event>()\n\nexport function enterEvent(event: H3Event) {\n  eventStorage.enterWith(event)\n}\n","ts",[79,212,213,246,253,285,304],{"__ignoreMap":77},[82,214,215,219,223,227,230,234,237,240,243],{"class":84,"line":85},[82,216,218],{"class":217},"spNyl","const",[82,220,222],{"class":221},"sTEyZ"," eventStorage ",[82,224,226],{"class":225},"sMK4o","=",[82,228,229],{"class":225}," new",[82,231,233],{"class":232},"s2Zo4"," AsyncLocalStorage",[82,235,236],{"class":225},"\u003C",[82,238,239],{"class":88},"H3Event",[82,241,242],{"class":225},">",[82,244,245],{"class":221},"()\n",[82,247,249],{"class":84,"line":248},2,[82,250,252],{"emptyLinePlaceholder":251},true,"\n",[82,254,256,260,263,266,269,273,276,279,282],{"class":84,"line":255},3,[82,257,259],{"class":258},"s7zQu","export",[82,261,262],{"class":217}," function",[82,264,265],{"class":232}," enterEvent",[82,267,268],{"class":225},"(",[82,270,272],{"class":271},"sHdIc","event",[82,274,275],{"class":225},":",[82,277,278],{"class":88}," H3Event",[82,280,281],{"class":225},")",[82,283,284],{"class":225}," {\n",[82,286,288,291,293,296,299,301],{"class":84,"line":287},4,[82,289,290],{"class":221},"  eventStorage",[82,292,163],{"class":225},[82,294,295],{"class":232},"enterWith",[82,297,268],{"class":298},"swJcz",[82,300,272],{"class":221},[82,302,303],{"class":298},")\n",[82,305,307],{"class":84,"line":306},5,[82,308,309],{"class":225},"}\n",[114,311,312],{},"After",[72,314,316],{"className":208,"code":315,"language":210,"meta":77,"style":77},"const eventStorage = new AsyncLocalStorage\u003CH3Event>()\n\nexport function runWithEvent\u003CT>(event: H3Event, callback: () => T): T {\n  return eventStorage.run(event, callback)\n}\n",[79,317,318,338,342,389,412],{"__ignoreMap":77},[82,319,320,322,324,326,328,330,332,334,336],{"class":84,"line":85},[82,321,218],{"class":217},[82,323,222],{"class":221},[82,325,226],{"class":225},[82,327,229],{"class":225},[82,329,233],{"class":232},[82,331,236],{"class":225},[82,333,239],{"class":88},[82,335,242],{"class":225},[82,337,245],{"class":221},[82,339,340],{"class":84,"line":248},[82,341,252],{"emptyLinePlaceholder":251},[82,343,344,346,348,351,353,356,359,361,363,365,368,371,373,376,379,382,385,387],{"class":84,"line":255},[82,345,259],{"class":258},[82,347,262],{"class":217},[82,349,350],{"class":232}," runWithEvent",[82,352,236],{"class":225},[82,354,355],{"class":88},"T",[82,357,358],{"class":225},">(",[82,360,272],{"class":271},[82,362,275],{"class":225},[82,364,278],{"class":88},[82,366,367],{"class":225},",",[82,369,370],{"class":232}," callback",[82,372,275],{"class":225},[82,374,375],{"class":225}," ()",[82,377,378],{"class":217}," =>",[82,380,381],{"class":88}," T",[82,383,384],{"class":225},"):",[82,386,381],{"class":88},[82,388,284],{"class":225},[82,390,391,394,397,399,402,404,406,408,410],{"class":84,"line":287},[82,392,393],{"class":258},"  return",[82,395,396],{"class":221}," eventStorage",[82,398,163],{"class":225},[82,400,401],{"class":232},"run",[82,403,268],{"class":298},[82,405,272],{"class":221},[82,407,367],{"class":225},[82,409,370],{"class":221},[82,411,303],{"class":298},[82,413,414],{"class":84,"line":306},[82,415,309],{"class":225},[417,418,419],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}",{"title":77,"searchDepth":248,"depth":248,"links":421},[422,423,424,425,426],{"id":69,"depth":248,"text":70},{"id":111,"depth":248,"text":112},{"id":152,"depth":248,"text":153},{"id":166,"depth":248,"text":167},{"id":196,"depth":248,"text":197,"children":427},[428],{"id":201,"depth":255,"text":202},"Report AsyncLocalStorage#enterWith() calls whose failure is not handled, outside a try\u002Fcatch or in one whose catch throws, in code that targets Cloudflare Workers.",[58],"md","nitro",{},{"title":435},"ALS enterWith","\u002Fnitro\u002Frules\u002Fcloudflare\u002Fno-unguarded-als-enterwith","Run the work inside als.run(store, callback) so the store is scoped to the callback. If the call has to stay for Node.js runtimes, wrap it in try\u002Fcatch and keep a fallback that does not depend on enterWith().",{"title":50,"description":429},"nitro\u002Frules\u002Fcloudflare\u002Fno-unguarded-als-enterwith","workerd implements AsyncLocalStorage run(), exit(), getStore(), bind(), and snapshot(), but enterWith() throws `asyncLocalStorage.enterWith() is not implemented`, with nodejs_compat or nodejs_als enabled. Code that works in Node.js then fails the request on Cloudflare. The rule runs when Project Inventory shows a Cloudflare target for the workspace package: a wrangler config, a cloudflare Nitro preset, Cloudflare tooling dependencies such as wrangler or @cloudflare\u002Fworkers-types, a cloudflare package keyword, or `cloudflare:` imports in the file.","Zv-IiBuCjmQBHu52ZY0boCY61Mtd-WglbI1FPpO2O5s",1795268794999]