How can I get the dimensions of a newly-created material node via Python?
There seems to be a solution to this (see below). Keep in mind, though, that while in general this approach is not recommended, in some cases it may work just fine.

Add this call to your script to force a re-draw, which will update the node’s dimensions properly.

bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)


Tip: if you add multiple nodes to the hierarchy (via your script) it may be smarter to add all nodes first then call this only once to minimize messing with blender’s drawing loop.

You can read more about this here:

https://docs.blender.org/api/2.79/info_gotcha.html?highlight=redraw#can-i-redraw-during-the-script

To be honest, I don’t understand exactly why blender doesn’t update the node’s dimensions right after it is added to the node hierarchy. It may be just an oversight, or perhaps blender really needs to re-draw everything once before it can figure out the dimensions.