{"record":{"id":"c356506414b9dfa6","repo":"microsoft/playwright","slug":"serialize-expected-an-array-of-map-set","errorCode":null,"errorMessage":"serialize: expected an array of (Map|Set)","messagePattern":"serialize: expected an array of \\(Map\\|Set\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/client/jsHandle.ts","lineNumber":153,"sourceCode":"    await Promise.all(exposePromises);\n    return serialized;\n  }, { internal: true });\n}\n\nexport function parseResult(value: channels.SerializedValue): any {\n  return parseSerializedValue(value, undefined);\n}\n\nexport function assertMaxArguments(count: number, max: number): asserts count {\n  if (count > max)\n    throw new Error('Too many arguments. If you need to pass more than 1 argument to the function wrap them in an object.');\n}\n\nexport function assertEvaluateOptions(options: any) {\n  if (options !== undefined && (typeof options !== 'object' || options === null || Array.isArray(options)))\n    throw new Error('Too many arguments. If you need to pass more than 1 argument to the function wrap them in an object.');\n  if (options?.serialize !== undefined && (!Array.isArray(options.serialize) || options.serialize.some((type: unknown) => type !== 'Map' && type !== 'Set')))\n    throw new Error('serialize: expected an array of (Map|Set)');\n}\n","sourceCodeStart":135,"sourceCodeEnd":155,"githubUrl":"https://github.com/microsoft/playwright/blob/f1d33b5029be8bbc1095fe88e559117fa3a6243b/packages/playwright-core/src/client/jsHandle.ts#L135-L155","documentation":"assertEvaluateOptions validates the optional options bag passed to evaluate/evaluateHandle/$eval/$$eval/addInitScript. The 'serialize' option must be an array containing only the strings 'Map' or 'Set', naming which built-in types may round-trip through the call. Any non-array, or an array holding other values, is rejected with this error.","triggerScenarios":"Calling page.evaluate / locator.evaluate / frame.evaluate / evaluateHandle / $eval / $$eval / addInitScript with an options argument whose 'serialize' property is not an array of only 'Map' and 'Set' — e.g. { serialize: true }, { serialize: 'Map' }, { serialize: ['Map','Object'] }.","commonSituations":"Typos like serialize: 'Map' instead of ['Map'], copying options from a different feature's docs, passing 'Object' or 'Date' expecting support when only Map/Set are allowed, or stuffing extra evaluate arguments into the options object after seeing the 'Too many arguments' error.","solutions":["Wrap serialize in an array containing only 'Map' and/or 'Set': { serialize: ['Map', 'Set'] }.","Remove the serialize option entirely — it is optional.","Pass extra evaluated-function arguments via the arg parameter, not the options object.","Check each entry is the exact string 'Map' or 'Set'."],"exampleFix":"// before\nawait page.evaluate(fn, arg, { serialize: 'Map' });\n// after\nawait page.evaluate(fn, arg, { serialize: ['Map', 'Set'] });","handlingStrategy":"validation","validationCode":"function validSerializeOptions(options?: { serialize?: string[] }): boolean {\n  return options?.serialize === undefined ||\n    (Array.isArray(options.serialize) && options.serialize.every(t => t === 'Map' || t === 'Set'));\n}","typeGuard":"function isSerializeArray(v: unknown): v is ('Map' | 'Set')[] {\n  return Array.isArray(v) && v.every((t): t is 'Map' | 'Set' => t === 'Map' || t === 'Set');\n}","tryCatchPattern":"try {\n  await page.evaluate(fn, arg, { serialize: ['Map', 'Set'] });\n} catch (e) {\n  if ((e as Error).message.startsWith('serialize:')) {\n    // fall back to no serialize option\n    await page.evaluate(fn, arg);\n  } else throw e;\n}","preventionTips":["Always pass serialize as an array literal: ['Map'] or ['Map', 'Set'].","Omit the serialize option unless you actually transfer Map/Set values.","Only 'Map' and 'Set' are accepted — do not try 'Object', 'Date', etc.","Keep evaluated-function extra arguments in the arg parameter, not the options bag."],"tags":["serialization","evaluate","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"f1d33b5029be8bbc1095fe88e559117fa3a6243b","analyzedAt":"2026-09-21T21:58:31.278Z","contentChangedAt":"2026-09-21T21:58:31.278Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}