faastjs > CommonOptions > validateSerialization
CommonOptions.validateSerialization property
Check arguments and return values from cloud functions are serializable without losing information. Default: true.
Signature:
validateSerialization?: boolean;
Remarks
Arguments to cloud functions are automatically serialized with JSON.stringify
with a custom replacer that handles built-in JavaScript types such as Date
and Buffer
. Return values go through the same process. Some JavaScript objects cannot be serialized. By default validateSerialization
will verify that every argument and return value can be serialized and deserialized without losing information. A FaastError
will be thrown if faast.js detects a problem according to the following procedure:
Serialize arguments and return values with
JSON.stringify
using a specialreplacer
function.Deserialize the values with
JSON.parse
with a specialreviver
function.Use assert.deepStringEqual to compare the original object with the deserialized object from step 2.
There is some overhead to this process because each argument is serialized and deserialized, which can be costly if arguments or return values are large.