[{"data":1,"prerenderedAt":442},["ShallowReactive",2],{"navigation_docs":3,"diagnostic-content-NITRO0024":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,"code":431,"description":432,"docsUrl":58,"extension":433,"fix":434,"framework":435,"meta":436,"navigation":186,"pack":60,"path":437,"ruleId":61,"rulePath":62,"seo":438,"severity":63,"source":64,"sourceUrl":65,"stem":439,"why":440,"__hash__":441},"diagnostics\u002Fdiagnostics\u002FNITRO0024.md","NITRO0024: Guard AsyncLocalStorage#enterWith on Cloudflare",{"type":52,"value":53,"toc":421},"minimark",[54,66,71,109,113,123,127,132,135,245,248,351,355,358,389,393,405,409,417],[55,56],"rule-metadata",{"category":57,"docsUrl":58,"fix":59,"pack":60,"ruleId":61,"rulePath":62,"severity":63,"source":64,"sourceUrl":65},"runtime","https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002Fruntime-apis\u002Fnodejs\u002Fasynclocalstorage\u002F","suggestion","vite-doctor\u002Fnitro","nitro\u002Fcloudflare\u002Fno-unguarded-als-enterwith","\u002Fnitro\u002Frules\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},"why-it-happens","Why it happens",[72,73,74,75,79,80,79,83,79,86,89,90,93,94,97,98,96,101,104,105,108],"p",{},"workerd implements AsyncLocalStorage ",[76,77,78],"code",{},"run()",", ",[76,81,82],{},"exit()",[76,84,85],{},"getStore()",[76,87,88],{},"bind()",", and ",[76,91,92],{},"snapshot()",", but ",[76,95,96],{},"enterWith()"," throws ",[76,99,100],{},"asyncLocalStorage.",[76,102,103],{}," 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 ",[76,106,107],{},"cloudflare:"," imports in the file.",[67,110,112],{"id":111},"fix","Fix",[72,114,115,116,119,120,122],{},"Run the work inside als.",[76,117,118],{},"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 ",[76,121,96],{},".",[67,124,126],{"id":125},"example","Example",[128,129,131],"h3",{"id":130},"scope-the-store-with-run","Scope the store with run()",[72,133,134],{},"Before",[136,137,142],"pre",{"className":138,"code":139,"language":140,"meta":141,"style":141},"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","",[76,143,144,181,188,220,239],{"__ignoreMap":141},[145,146,149,153,157,161,164,168,171,175,178],"span",{"class":147,"line":148},"line",1,[145,150,152],{"class":151},"spNyl","const",[145,154,156],{"class":155},"sTEyZ"," eventStorage ",[145,158,160],{"class":159},"sMK4o","=",[145,162,163],{"class":159}," new",[145,165,167],{"class":166},"s2Zo4"," AsyncLocalStorage",[145,169,170],{"class":159},"\u003C",[145,172,174],{"class":173},"sBMFI","H3Event",[145,176,177],{"class":159},">",[145,179,180],{"class":155},"()\n",[145,182,184],{"class":147,"line":183},2,[145,185,187],{"emptyLinePlaceholder":186},true,"\n",[145,189,191,195,198,201,204,208,211,214,217],{"class":147,"line":190},3,[145,192,194],{"class":193},"s7zQu","export",[145,196,197],{"class":151}," function",[145,199,200],{"class":166}," enterEvent",[145,202,203],{"class":159},"(",[145,205,207],{"class":206},"sHdIc","event",[145,209,210],{"class":159},":",[145,212,213],{"class":173}," H3Event",[145,215,216],{"class":159},")",[145,218,219],{"class":159}," {\n",[145,221,223,226,228,231,234,236],{"class":147,"line":222},4,[145,224,225],{"class":155},"  eventStorage",[145,227,122],{"class":159},[145,229,230],{"class":166},"enterWith",[145,232,203],{"class":233},"swJcz",[145,235,207],{"class":155},[145,237,238],{"class":233},")\n",[145,240,242],{"class":147,"line":241},5,[145,243,244],{"class":159},"}\n",[72,246,247],{},"After",[136,249,251],{"className":138,"code":250,"language":140,"meta":141,"style":141},"const eventStorage = new AsyncLocalStorage\u003CH3Event>()\n\nexport function runWithEvent\u003CT>(event: H3Event, callback: () => T): T {\n  return eventStorage.run(event, callback)\n}\n",[76,252,253,273,277,324,347],{"__ignoreMap":141},[145,254,255,257,259,261,263,265,267,269,271],{"class":147,"line":148},[145,256,152],{"class":151},[145,258,156],{"class":155},[145,260,160],{"class":159},[145,262,163],{"class":159},[145,264,167],{"class":166},[145,266,170],{"class":159},[145,268,174],{"class":173},[145,270,177],{"class":159},[145,272,180],{"class":155},[145,274,275],{"class":147,"line":183},[145,276,187],{"emptyLinePlaceholder":186},[145,278,279,281,283,286,288,291,294,296,298,300,303,306,308,311,314,317,320,322],{"class":147,"line":190},[145,280,194],{"class":193},[145,282,197],{"class":151},[145,284,285],{"class":166}," runWithEvent",[145,287,170],{"class":159},[145,289,290],{"class":173},"T",[145,292,293],{"class":159},">(",[145,295,207],{"class":206},[145,297,210],{"class":159},[145,299,213],{"class":173},[145,301,302],{"class":159},",",[145,304,305],{"class":166}," callback",[145,307,210],{"class":159},[145,309,310],{"class":159}," ()",[145,312,313],{"class":151}," =>",[145,315,316],{"class":173}," T",[145,318,319],{"class":159},"):",[145,321,316],{"class":173},[145,323,219],{"class":159},[145,325,326,329,332,334,337,339,341,343,345],{"class":147,"line":222},[145,327,328],{"class":193},"  return",[145,330,331],{"class":155}," eventStorage",[145,333,122],{"class":159},[145,335,336],{"class":166},"run",[145,338,203],{"class":233},[145,340,207],{"class":155},[145,342,302],{"class":159},[145,344,305],{"class":155},[145,346,238],{"class":233},[145,348,349],{"class":147,"line":241},[145,350,244],{"class":159},[67,352,354],{"id":353},"verify-the-fix","Verify the fix",[72,356,357],{},"Run only this rule after editing so the report stays focused on the diagnostic you are closing:",[136,359,363],{"className":360,"code":361,"language":362,"meta":141,"style":141},"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",[76,364,365],{"__ignoreMap":141},[145,366,367,370,374,377,380,383,386],{"class":147,"line":148},[145,368,369],{"class":173},"pnpm",[145,371,373],{"class":372},"sfazB"," vite-doctor",[145,375,376],{"class":372}," .",[145,378,379],{"class":372}," --framework",[145,381,382],{"class":372}," nitro",[145,384,385],{"class":372}," --rules",[145,387,388],{"class":372}," nitro\u002Fcloudflare\u002Fno-unguarded-als-enterwith\n",[67,390,392],{"id":391},"useful-links","Useful links",[394,395,396],"ul",{},[397,398,399],"li",{},[400,401,404],"a",{"href":58,"rel":402},[403],"nofollow","Upstream docs",[67,406,408],{"id":407},"related-rule","Related rule",[394,410,411],{},[397,412,413],{},[400,414,415],{"href":62},[76,416,61],{},[418,419,420],"style",{},"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 .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}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}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 .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}",{"title":141,"searchDepth":183,"depth":183,"links":422},[423,424,425,428,429,430],{"id":69,"depth":183,"text":70},{"id":111,"depth":183,"text":112},{"id":125,"depth":183,"text":126,"children":426},[427],{"id":130,"depth":190,"text":131},{"id":353,"depth":183,"text":354},{"id":391,"depth":183,"text":392},{"id":407,"depth":183,"text":408},"NITRO0024","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.","md","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().","nitro",{},"\u002Fdiagnostics\u002Fnitro0024",{"title":50,"description":432},"diagnostics\u002FNITRO0024","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.","nZ_K4wHGaD8fPMDRwSW62p_smob1G9g6vpmCGWn8qPE",1795268817454]