Support my work ♥

Error when serializing sealed object in meteor

Today, I worked on a meteor project. It is a framework building on nodejs and WebSocket that takes care of syncing state between the server and the client.

Sadly, one of the building blocks of meteor is no longer maintained. This means the project is stuck in a technical corner with no way out. The future will tell if the project or a spiritual successor can be built with the current stack around async and await.

The problem

I needed to move a static API dictionary into the configuration.

This means it had to be available when using import Categories because the code requires that. As well as being controlled by the deployment which feeds Meteor.settings.

The error

This lead to this error visible to clients when opening the application:

Couldn't find a template named "findWrap" or "findWrap". Are you sure you defined it?

The reason is that the framework tries to transport a part the object Meteor.settings. However, that object is sealed. So the framework can not inject the needed prototype functions for the serialisation.

The fix

We have to copy the content of the sealed object into a live object that the framework can extend and serialize.

// Make a deep copy
const Categories = Object.assign({}, Meteor.settings.public.categories);

export default Categories;

links

social