First update always increase size

my server code:

const decoder = decoding.createDecoder(new Uint8Array(message));
      const messageType = decoding.readVarUint(decoder);
      if (messageType === 0) {
        // send initial doc state
        const stateVector = decoding.readVarUint8Array(decoder);
        const update = Y.encodeStateAsUpdate(model.ydoc, stateVector);
        const encoder = encoding.createEncoder();
        encoding.writeVarUint(encoder, 1);
        encoding.writeVarUint8Array(encoder, update);
        ws.send(encoding.toUint8Array(encoder), true);
      } else if (messageType === 1) {
        const update = decoding.readVarUint8Array(decoder);
        Y.applyUpdate(model.ydoc, update, ws);
        model.change++;
        if (model.clients > 1) {
          const encoder = encoding.createEncoder();
          encoding.writeVarUint(encoder, 1);
          encoding.writeVarUint8Array(encoder, update);
          ws.publish(wdata.fid, encoding.toUint8Array(encoder));
        }
      }

client code:

let data=event.data
      if(data=='1'){
        // request initial doc state
        const encoder = new encoding.Encoder();
        encoding.writeVarUint(encoder, 0); 
        encoding.writeVarUint8Array(encoder, Y.encodeStateVector(doc)); 
        ws.send(encoding.toUint8Array(encoder));
      }else{
        const decoder = new decoding.Decoder(new Uint8Array(event.data));
        const messageType = decoding.readVarUint(decoder);
        if (messageType === 1) {
          const update = decoding.readVarUint8Array(decoder);
          Y.applyUpdate(doc, update);
          if(first){
            console.log('update',update.length)
            first=false
            cb()
          }
        }
      }

when i refresh the browser, why the update.length is increasing (23 bytes each time)? i dont change anything.

I would say that this is unlikely. Yjs only increases in size when you change the document. This has been thoroughly tested.

Maybe try registering an observer to check the changes that are produced implicitly.

If you still think the issue is with Yjs, then try to reproduce the issue in a reproducible test case.

i add observer on server side, and find it’s my program bug.
sorry.
thanks.