-
-
Notifications
You must be signed in to change notification settings - Fork 208
Closed
Labels
bugConfirmed bugConfirmed bug
Description
I'm trying to serialize some recursive directory tree without success.
And I do not find any solution, can you please help me?
Code
const fastify = require('fastify')({ logger: { prettyPrint: { translateTime: true } } })
fastify.route({
url: '/',
method: 'GET',
schema: {
response: {
200: {
definitions: {
directory: {
type: 'object',
properties: {
name: { type: 'string' },
subDirectories: {
type: 'array',
items: { $ref: '#/definitions/directory' },
default: []
}
}
}
},
type: 'array',
items: { $ref: '#/definitions/directory' }
}
}
},
handler: async (request, reply) => {
reply.send([
{ name: 'directory 1', subDirectories: [] },
{ name: 'directory 2',
subDirectories: [
{ name: 'directory 2.1', subDirectories: [] },
{ name: 'directory 2.2', subDirectories: [] }
] }
])
}
})
fastify.listen().catch(error => {
fastify.log.error(error)
process.exit(1)
})
Error
[2019-08-12 09:54:23.895 +0000] ERROR (59647 on xxx.local): Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
at String.replace (<anonymous>)
at sanitizeKey (/Users/xxx/workspace/yyy/node_modules/fast-json-stringify/index.js:520:19)
at Object.keys.forEach (/Users/xxx/workspace/yyy/node_modules/fast-json-stringify/index.js:544:21)
at Array.forEach (<anonymous>)
at buildCode (/Users/xxx/workspace/yyy/node_modules/fast-json-stringify/index.js:534:40)
at buildCodeWithAllOfs (/Users/xxx/workspace/yyy/node_modules/fast-json-stringify/index.js:644:21)
at buildInnerObject (/Users/xxx/workspace/yyy/node_modules/fast-json-stringify/index.js:662:10)
at buildObject (/Users/xxx/workspace/yyy/node_modules/fast-json-stringify/index.js:753:9)
at nested (/Users/xxx/workspace/yyy/node_modules/fast-json-stringify/index.js:912:19)
at Object.keys.forEach (/Users/xxx/workspace/yyy/node_modules/fast-json-stringify/index.js:603:20)
paz-raon, kalda341, lazharichir and gilles-crealp
Metadata
Metadata
Assignees
Labels
bugConfirmed bugConfirmed bug