一次 Chrome 缓存锁的有趣探索
昨天同事问我关于 Node Event Loop 的问题,代码如下:
const Koa = require('koa')
const app = new Koa()
const logger = require('koa-logger')
let index = 0
const sleep = delay => new Promise(resolve => setTimeout(resolve, delay))
app.use(logger())
app.use(async ctx => {
await sleep(500)
ctx.body = index++
})
app.listen(3000)