升级@hapi/hapi至21.3.2后缓存系统实现报错求助
Hapi 从v11升级到v21.3.2后添加缓存系统报错
环境信息
Node : 16.20.2 @hapi/hapi : 21.3.2 @hapi/catbox : 12.1.1 @hapi/catbox-memory : 6.0.1
错误信息
TypeError: refAnnotations.errors[cacheKey].push is not a function at exports.ValidationError.exports.error [as annotate] (...path/server/node_modules/@hapi/validate/lib/annotate.js:53:53)
服务器初始化及缓存实现代码
const Hapi = require('@hapi/hapi'); const catboxMemory = require('@hapi/catbox-memory'); ... rest of imports const init = async () => { const server = Hapi.Server({ host: 'localhost', port: config.port, cache: { name: 'memoryCache', provider: { constructor: catboxMemory } }, }); // Register the plugins await server.register([ H2o2, Inert, Vision, dataPlugin, routesPlugin ]); const start = async () => { ... function that handle views await server.start(); }; start(); console.log('Server running on %s', server.info.uri); }; process.on('unhandledRejection', (err) => { console.log(err); process.exit(1); }); init();
问题描述
将Hapi服务器从v11版本升级至最新v21.3.2版本,完成重构后服务器可正常运行,但添加缓存系统时触发上述错误,无法定位是实现逻辑问题还是版本适配问题。尝试过多种语法调整,查阅Hapi官方文档也未找到有效解决方向,不清楚遗漏了哪些必要配置或步骤。
内容的提问来源于stack exchange,提问作者Sylvain Jacot
相关产品推荐
相关产品推荐

