Skip to content

Latest commit

 

History

History
30 lines (19 loc) · 1.61 KB

faastjs.commonoptions.validateserialization.md

File metadata and controls

30 lines (19 loc) · 1.61 KB
id title hide_title
faastjs.commonoptions.validateserialization
CommonOptions.validateSerialization property
true

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:

  1. Serialize arguments and return values with JSON.stringify using a special replacer function.

  2. Deserialize the values with JSON.parse with a special reviver function.

  3. 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.